-
Notifications
You must be signed in to change notification settings - Fork 5
Edge-to-edge behaviour on Android R #4
Comments
My first reaction would be that API30 has the expected behavior, since top padding is applied twice. I added a new example called "Issue 4" where I tried to reproduce the issue you described. Here is the screenshot of the screens with the The code can be found in |
I was able to tweak the sample app to replicate the issue. It seem the behaviour of WindowInsets have changed in R, but only if your app also target R. While stepping through the code, I saw that CollapsingToolbarLayout consume the insets (see https://android.googlesource.com/platform/frameworks/support/+/6ba61c5/design/src/android/support/design/widget/CollapsingToolbarLayout.java#167). From what I see, in R this "consume" is ignored and the insets are still propagated to the child view. Below R this consume is not ignored and the children never get the WindowInset. That is why in R the Fragment padding is set. But not in Q. Let me know of what you think of the sample and my findings! :) |
Thanks for debugging it Thierry-Dimitri! Your findings make perfectly sense. Initially, to avoid such inconsistencies, I decided to always install the WindowInsetsListener at the top most view, wich is the content view of the activity. This would also ensure that the listener is always invoked, independently where in the view hierarchy Unfortunately That do you think? Would you be able to adopt the change in you app without adding any custom if-else code? |
Hi @beworker The latest release of What do you think? :) |
@beworker I found another problem with R :( |
@ThierryD Both issues should have the same reason - the library ignores inset consumption. It can be fixed rather easily, but I'm short on time at the moment. I might find some time on the weekend however. |
@beworker Hey no worry. I understand that sometimes we do not have time to work on our hobby project. I just wanted to raise this new issue :) |
On Android R, the behaviour of
ViewCompat.setOnApplyWindowInsetsListener
has changed to support IME (see for example https://proandroiddev.com/exploring-windowinsets-on-android-11-a80cf8fe19be).I currently have a fragment that is used in two different location in my app:
My app is build like so:
edgeToEdge()
to include padding for the top system baredgeToEdge()
to include padding for the top system barIn API 29, the fragment inside the CoordinatorLayout won't get
OnApplyWindowInsetsListener
calledIn API 30, the fragment do get
OnApplyWindowInsetsListener
called (probably due to the change for the new IME code)Now, my fix right now is just to check if the fragment is not inside a CoordinatorLayout to call
fragment.edgeToEdge()
.But I'm wondering if there is anything that could be done in the edge-to-edge library to fix this instead. What do you think?
The text was updated successfully, but these errors were encountered: