maui icon indicating copy to clipboard operation
maui copied to clipboard

[Android] If to set SystemUiVisibility = SystemUiFlags.HideNavigation on Android, then Flyout Items are not displayed.

Open ainur13 opened this issue 4 years ago • 7 comments

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

  1. Create app with Flyout
  2. Override OnCreate method in MainActivity on Android Platform
  3. Write inside OnCreate method Window.DecorView.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky | SystemUiFlags.HideNavigation);
  4. 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

ainur13 avatar Jul 07 '22 04:07 ainur13

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 avatar Jul 07 '22 06:07 nzcoward

@nzcoward Will it work on lower versions of Android?

ainur13 avatar Jul 07 '22 06:07 ainur13

AndroidX works on API 28+, but I'm pretty sure not all features will. I haven't tested on lower than 30.

nzcoward avatar Jul 07 '22 06:07 nzcoward

@nzcoward Tested on Android 10: unfortunately, ViewCompat.GetWindowInsetsController(Window.DecorView) returns null at runtime and causes exception :(

ainur13 avatar Jul 07 '22 06:07 ainur13

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

nzcoward avatar Jul 07 '22 06:07 nzcoward

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;

zslocum avatar Aug 05 '22 22:08 zslocum

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.