简体   繁体   中英

Navigation bar wont hide after closing keyboard

When I fill in a input field and close the keyboard my navigation bar wont hide.

Before I fill in the input field its hidden.

I tried multiple solutions but none of them work for me.

this.Window.AddFlags(WindowManagerFlags.Fullscreen); // hide the status bar

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;

This is the code i have in my OnCreate method in my MainActivity .

Here is the demo.

Implement View.IOnSystemUiVisibilityChangeListener interface:

    public void OnSystemUiVisibilityChange([GeneratedEnum] StatusBarVisibility visibility)
    {
        if (((int)visibility & (int)SystemUiFlags.Fullscreen) == 0)
        {
            Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;
        }

    }

Add the listener for your DecorView:

Window.DecorView.SetOnSystemUiVisibilityChangeListener(this);

Override OnWindowFocusChanged :

    public override void OnWindowFocusChanged(bool hasFocus)
    {
        base.OnWindowFocusChanged(hasFocus);
        Window.DecorView.SystemUiVisibility = (StatusBarVisibility)((int)SystemUiFlags.Fullscreen
            | (int)SystemUiFlags.ImmersiveSticky
            | (int)SystemUiFlags.LayoutHideNavigation
            | (int)SystemUiFlags.LayoutStable
            | (int)SystemUiFlags.HideNavigation);
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM