1.介绍
介于PDA做的WMS系统,由于PDA尺寸限制,需要隐藏状态栏和导航栏,节省空间!
2.解决方案
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
//隐藏状态栏
this.Window.AddFlags(WindowManagerFlags.Fullscreen|WindowManagerFlags.TurnScreenOn);
//隐藏底部导航栏
WindowManagerLayoutParams windowManager = Window.Attributes;
var uiOptions = (int)Window.DecorView.SystemUiVisibility;
var newUiOptions = (int)uiOptions;
newUiOptions = (int)SystemUiFlags.HideNavigation | (int)SystemUiFlags.Immersive | (int)SystemUiFlags.ImmersiveSticky;
windowManager.SystemUiVisibility = (StatusBarVisibility)newUiOptions;
Window.Attributes= windowManager;
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}
以上代码就可以实现 默认隐藏状态栏和底部导航栏 了!欢迎大家提问题,请多多点赞哦!