I'm writing an app that has one activity and a bunch of fragments and one of those fragments is fullscreen. In order to achieve that, I'm trying to use the System UI Visibility flags.
For the fullscreen fragment, I set the visibility:
layout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
As soon as I do that, the window insets change to values that don't seem to make any sense. Then, when I exit that fullscreen fragment, I wind up with wrong padding on my view (based on the weird insets)
Does anyone know what's going on here? The way I understand the window insets must be wrong, because this behavior seems completely counter intuitive. Any insight would be appreciated.
To view the full source of the test app I wrote to illustrate the problem go here:
https://github.com/dapp/visibilitytest
I have the same problem today. I am using a NavigationView from design library. When I exit full screen, there are insects on top and bottom of NavigationView, which is ugly.
I debug and dig into the source code of NavigationView and find following solution:
Please use setFitsSystemWindows(false) method for your view, in my case, for NavigationView, to avoid impact of status bar and navigation bar changes.
I found there is OnApplyWindowInsetsListener in NavigationView's super class: ScrimInsetsFrameLayout, then I clear this listener to avoid impact when full screen is enabled/disabled, by using ViewCompat.setOnApplyWindowInsetsListener(mNavigationView, null).
Now the NavigationView behaves correctly when exit full screen, hope this helps for your problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With