Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin.Android: Hide StatusBar and Notification in Fullscreen mode

I am trying to hide statusbar and notification in fullscreen mode. User should not be able to pull/swipe down status/notification bar in Xamarin android.

In native android it is working fine with below property.

View decorView = getWindow().getDecorView(); 
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

getWindow().setFlags(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);

Equivalent to TYPE_APPLICATION_OVERLAY in xamarin not able to get.

Any solution for Xamarin.Android?

I have tried below properties for xamarin:

View decorView = Window.DecorView;
var uiOptions = (int)decorView.SystemUiVisibility;
var newUiOptions = (int)uiOptions;      
newUiOptions |= (int)SystemUiFlags.HideNavigation;
newUiOptions |= (int)SystemUiFlags.LayoutHideNavigation;
newUiOptions |= (int)SystemUiFlags.LayoutFullscreen;
newUiOptions |= (int)SystemUiFlags.Fullscreen;
newUiOptions |= (int)SystemUiFlags.ImmersiveSticky; 
decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;

Window.AddFlags(WindowManagerFlags.TranslucentNavigation);
Window.AddFlags(WindowManagerFlags.TranslucentStatus);
Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);

Help will be appreciated. Thank you

Answers

  • Xammy10Xammy10 Member ✭✭✭

    Try using this code sir

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

    The only problem in that is, if the focus is gone on a certain method you call this codes, the navigation and status bar will show again. You need to add this to every your gonna click or tap like button, spinner, ect.

Sign In or Register to comment.