有没有办法让我在 Android 上的 Xamarin Forms 应用程序进入全屏或沉浸模式?
我尝试了以下操作,状态栏上的所有控件都隐藏了,但状态栏本身仍在显示。任何帮助,请
var newUiOptions = (int)SystemUiFlags.LayoutStable;
newUiOptions |= (int)SystemUiFlags.LayoutHideNavigation;
newUiOptions |= (int)SystemUiFlags.LayoutFullscreen;
newUiOptions |= (int)SystemUiFlags.HideNavigation;
newUiOptions |= (int)SystemUiFlags.Fullscreen;
newUiOptions |= (int)SystemUiFlags.Immersive;
//newUiOptions |= (int)SystemUiFlags.ImmersiveSticky;
decorView.SystemUiVisibility = (StatusBarVisibility)newUiOptions;
导航栏是隐藏的,但不是状态栏。
最佳答案
您可以通过在 theme
属性中设置 Activity
来做到这一点:
[Activity (Label = "@string/app_name", MainLauncher = true, Theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen")]
或者,如果您仅在特定 Activity 全屏之后,则在 Activity
OnCreate
方法中设置以下标志:this.Window.AddFlags(WindowManagerFlags.Fullscreen);
this.Window.ClearFlags(WindowManagerFlags.Fullscreen);
关于android - 为 Android 全屏制作 Xamarin 表单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34899789/