7

无论如何让我在 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;

导航栏是隐藏的,但不是状态栏。

4

2 回答 2

12

您可以通过设置属性theme来做到这一点:Activity

[Activity (Label = "@string/app_name", MainLauncher = true, Theme = "@android:style/Theme.Black.NoTitleBar.Fullscreen")]

或者,如果您仅在特定活动之后全屏,则在活动OnCreate方法中设置以下标志:

this.Window.AddFlags(WindowManagerFlags.Fullscreen);
this.Window.ClearFlags(WindowManagerFlags.Fullscreen);
于 2016-01-22T10:56:39.030 回答
2
protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our game view from the layout resource,
            // and attach the view created event to it
            CCGameView gameView = (CCGameView)FindViewById(Resource.Id.GameView);
            gameView.ViewCreated += LoadGame;
            gameView.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.HideNavigation
                | SystemUiFlags.Fullscreen
                | SystemUiFlags.LayoutFullscreen
                | SystemUiFlags.LayoutHideNavigation
                | SystemUiFlags.Immersive);


        }
于 2017-03-05T14:06:11.353 回答