簡體   English   中英

關閉鍵盤后導航欄不會隱藏

[英]Navigation bar wont hide after closing keyboard

當我填寫輸入字段並關閉鍵盤時,我的導航欄將不會隱藏。

在我填寫輸入字段之前,它是隱藏的。

我嘗試了多種解決方案,但沒有一種適合我。

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;

這是我MainActivity OnCreate方法中的代碼。

是演示。

實現View.IOnSystemUiVisibilityChangeListener接口:

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

    }

為您的DecorView添加偵聽器:

Window.DecorView.SetOnSystemUiVisibilityChangeListener(this);

覆蓋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);
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM