【问题标题】:Make Xamarin Forms for Android Fullscreen为 Android 全屏制作 Xamarin 表单
【发布时间】:2016-01-20 12:13:22
【问题描述】:

是否可以让我在 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;

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

【问题讨论】:

    标签: android xamarin xamarin.android xamarin.forms android-immersive


    【解决方案1】:

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

    [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);
    

    【讨论】:

    • 谢谢。没有尝试将主要活动置于全屏模式,只是一个 Xamarin.Forms 内容页面,并且发现该问题与主-详细信息导航有关。
    • @Paulus 我想我遇到了同样的问题。主细节导航和应用程序不是全屏的。你的问题是什么,你是如何解决的?
    【解决方案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);
    
    
            }
    

    【讨论】:

      猜你喜欢
      • 2019-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-20
      • 1970-01-01
      • 1970-01-01
      • 2014-09-22
      • 1970-01-01
      相关资源
      最近更新 更多