[Android] If to set SystemUiVisibility = SystemUiFlags.HideNavigation on Android, then Flyout Items are not displayed.
Description
I try to make my app full screen on Android without status bar on top and navigation bar on botttom, so in MainActivity I override OnCreate method and write inside following code:
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)
(SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky | SystemUiFlags.HideNavigation);
I know that it's deprecated, but it still works! =)
But the problem is that SystemUiFlags.HideNavigation prevents flyout work properly: flyout items stop to be visible or not generated at all, idk)
If I remove SystemUiFlags.HideNavigation everything works fine, but my app then have navigation on bottom.
Steps to Reproduce
- Create app with Flyout
- Override OnCreate method in MainActivity on Android Platform
- Write inside OnCreate method
Window.DecorView.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky | SystemUiFlags.HideNavigation); - Run Android and see that flyout items are not displayed
Version with bug
6.0.400 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 11
Did you find any workaround?
No response
Relevant log output
No response
As you are on Android 11, can you use AndroidX as a workaround?
using AndroidX.Core.View;
WindowCompat.SetDecorFitsSystemWindows(Window, false);
WindowInsetsControllerCompat windowInsetsControllerCompat = ViewCompat.GetWindowInsetsController(Window.DecorView);
windowInsetsControllerCompat.Hide(WindowInsetsCompat.Type.SystemBars() | WindowInsetsCompat.Type.NavigationBars());
windowInsetsControllerCompat.SystemBarsBehavior = WindowInsetsControllerCompat.BehaviorShowTransientBarsBySwipe;
`
@nzcoward Will it work on lower versions of Android?
AndroidX works on API 28+, but I'm pretty sure not all features will. I haven't tested on lower than 30.
@nzcoward Tested on Android 10: unfortunately, ViewCompat.GetWindowInsetsController(Window.DecorView) returns null at runtime and causes exception :(
Are you doing it in OnCreate and OnResume in MainActivity? I know I had some issues with it at one point in XF not being available at the right time. But not long after I upgraded to API 30 so I never looked further into it
In case anyone else comes through looking for a workaround that works on API 29 (at least within emulator, did not try lower) through API 31 (on device, Pixel 3).
You can actually instantiate a WindowInsetsControllerCompat within OnCreate:
WindowCompat.SetDecorFitsSystemWindows(Window, false);
WindowInsetsControllerCompat windowInsetsControllerCompat = new WindowInsetsControllerCompat(Window, Window.DecorView);
windowInsetsControllerCompat.Hide(WindowInsetsCompat.Type.SystemBars() | WindowInsetsCompat.Type.NavigationBars());
windowInsetsControllerCompat.SystemBarsBehavior = WindowInsetsControllerCompat.BehaviorShowTransientBarsBySwipe;
Hi @Ainur13. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.