Hiding the navigation soft keys Android Xamarin Forms

One might come across a case where it is needed to hide the on screen softkeys on android (The home, back and windows button) either for full screen display or space allocation to app. This is easily archeiveable by setting some ui options as demostrated below.

public void ImmersiveMode()
int uiOptions = (int)(Forms.Context as Activity).Window.DecorView.SystemUiVisibility;
uiOptions |= (int)SystemUiFlags.Fullscreen;
uiOptions |= (int)SystemUiFlags.HideNavigation;
uiOptions |= (int)SystemUiFlags.ImmersiveSticky;
(Forms.Context as Activity).Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;

The ImmersiveMode method can be called in the Mainactivity after the LoadApplication is called in the OnCreate method.


 protected override void OnCreate(Bundle savedInstanceState)
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;
            LoadApplication(new App());

Thats it. You are all set.

Before ImmersiveMode

After ImmersiveMode

All Rights Reserved

Let's register a Viblo Account to get more interesting posts.