how to use SystemUiFlags Enum

2021-07-04T15:09:35.757+00:00

Hi! Well I know it might be a bit silly but I really can't figure out how to use SystemUiFlags.HideNavigation;
I want my app to hide system navigation bar when the app enters fullscreen but I just don't get how to use it correctly. Originally I used (StatusBarVisibility)View.SystemUiFlagHideNavigation; but since it became deprecated I'd like to renew the code a bit. Can you help me out a little bit?

there's an article with the modern enum for doing this but I don't understand how to use it.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
0 comments No comments
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,221 Reputation points Microsoft Vendor
    2021-07-05T06:15:09.873+00:00

    Hello,
    Welcome to our Microsoft Q&A platform!

    You can use SystemUiFlags like following code

    var uiOptions =  
                    SystemUiFlags.HideNavigation |  
                    SystemUiFlags.LayoutHideNavigation |  
                    SystemUiFlags.LayoutFullscreen |  
                    SystemUiFlags.Fullscreen |  
                    SystemUiFlags.LayoutStable |  
                    SystemUiFlags.ImmersiveSticky;  
    Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;  
    

    I notice that systemUiVisibility is deprecated in Android R. You can use IWindowInsetsController.

     IWindowInsetsController insetsController = Window.InsetsController;  
     if (insetsController != null)  
      {  
        insetsController.Hide(WindowInsets.Type.NavigationBars());  
      }  
    

    In addition, you can hide NavigationBar by Xamarin.Forms

    NavigationPage.SetHasNavigationBar(this, false);  
    

    For more information you can refer to :
    https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/
    https://learn.microsoft.com/en-us/dotnet/api/android.views.view.systemuiflaghidenavigation?view=xamarin-android-sdk-9
    https://stackoverflow.com/questions/62577645/android-view-view-systemuivisibility-deprecated-what-is-the-replacement

    Best Regards,
    Wenyan Zhang


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful