Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide bottom bar of android (back, home) in xamarin forms?

How can I hide the bottom android bar (back button, home button) permanently in xamarin forms? I tried some code but its hiding it temporarily. When I touch the screen, it again shows. But I want to hide it completely.

like image 931
anand Avatar asked Aug 31 '16 11:08

anand


People also ask

How do you get rid of the bar at the bottom of android?

Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

What is xamarin shell?

Xamarin. Forms Shell reduces the complexity of mobile application development by providing the fundamental features that most mobile applications require, including: A single place to describe the visual hierarchy of an application. A common navigation user experience.


1 Answers

I appreciate I'm rather late to the party with this answer, but I thought I'd chuck this in here for anyone else who's had the torrid time I've had trying to figure this out.

My Droid MainActivity now looks like this:

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    global::Xamarin.Forms.Forms.Init(this, bundle);

    //====================================
    int uiOptions = (int)Window.DecorView.SystemUiVisibility;

    uiOptions |= (int)SystemUiFlags.LowProfile;
    uiOptions |= (int)SystemUiFlags.Fullscreen;
    uiOptions |= (int)SystemUiFlags.HideNavigation;
    uiOptions |= (int)SystemUiFlags.ImmersiveSticky;

    Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;
    //====================================

    LoadApplication(new Pages.App());
}

That bit between the commented equals is the sweet spot. Ideally it also needs to be called in the overriden OnStart and OnResume methods as well as OnCreate, to ensure the flags remain set.

If you use "Immersive" rather than "ImmersiveSticky" for that last flag it'll make the top status and bottom system nav bars disappear as required, but when they reappear (from dragging down at the top of the screen, for instance) the bottom one won't disappear again. Therefore using "ImmersiveSticky" is the kiddie.

like image 80
DrObey Avatar answered Oct 13 '22 04:10

DrObey