Status Update
Comments
il...@google.com <il...@google.com> #2
I'm marking this as "won't fix" as there's nothing Compose here can do, as this is a platform quirk that has been adjusted to be more predictable in recent API versions.
The crux of the issue here is the fitSystemWindows
in the extra View
, like you mentioned, and a platform change in API 30.
Prior to API 30, window insets were dispatched through the view hierarchy in a non-intuitive way: Rather than being a full breadth-first traversal, they would be dispatched in preorder. If the insets were consumed at any point (like if you use fitSystemWindows
), then the preorder would prevent insets from being dispatched to the rest of the view hierarchy. This is very unintuitive: It meant that sibling views (or views deeper in the tree) could stop later views from receiving the dispatch of insets.
In API 30, this behavior was changed to be more intuitive: Now, insets are dispatched in a top-down manner, so they can't be consumed in this weird, cross-tree way.
There's a couple solutions here:
- Avoid
fitSystemWindows
from views if you're handling insets manually - Override
dispatchApplyWindowInsets
in the view groups above where you havefitSystemWindows
defined, and manually perform the new, non-broken dispatching behavior. You can see a comparison of the two methods here:https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/view/ViewGroup.java;l=7341-7371;drc=6411c81462e3594c38a1be5d7c27d67294139ab8
zh...@gmail.com <zh...@gmail.com> #3
Using composable version 1.2.1, I could fix it using:
override fun onCreate(bundle: Bundle?) {
WindowCompat.setDecorFitsSystemWindows(window, false)
super.onCreate(bundle)
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q){
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
}
}
Then statusBarsPadding works as expected on Api 29
va...@gmail.com <va...@gmail.com> #4
[Deleted User] <[Deleted User]> #5
ne...@gmail.com <ne...@gmail.com> #6
I don't agree with this, because I want those methods. They are very useful.
sc...@gmail.com <sc...@gmail.com> #7
I think too this methods is useful. I create multibackstack with this methods
yo...@google.com <yo...@google.com> #8
This has started to block some downstream infrastructure work. Any chance we can get access to this soon, even as an option?
ka...@gmail.com <ka...@gmail.com> #9
il...@google.com <il...@google.com> #10
Re #9 - the whole point of ViewModels is to survive the destruction and later recreation of the same fragment, so yes, they'd be saved.
Description
Version used: androidx.fragment:fragment 1.1.0-alpha04
The current behavior is for fragments to destroy only their views when they are in the backstack. This makes their lifecycle way more complicated to deal with since you need to handle views being created and destroyed out from under you. You also may not notice you they aren't handling this until you put a fragment on the backstack since this (and FragmentPagerAdapter) are the only common cases where this will happen.
I propose changing the behavior to destroying fragments when they are put on the backstack and saving their instance state. Going back would re-create them with the saved state. I believe making this change in a version update should be ok since you already need to handle the recreation of fragments due to config changes. However, if a more gradual approach is desired, then a setter to FragmentManager could be added, and the docs could push you to enabling it, making it the default in the future.
Furthermore, the attach(), and detach() methods should be deprecated to discourage any other uses that cause this behavior.