当我填写输入字段并关闭键盘时,我的导航栏不会隐藏。
在我填写输入字段之前,它是隐藏的。
我尝试了多种解决方案,但它们都不适合我。
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;
这是我OnCreate
中MainActivity
方法中的代码。
答案 0 :(得分:0)
Here是演示。
实施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);
}