5

有沒有辦法讓我的Xamarin表單應用程序在Android上轉爲全屏或沉浸式模式?爲Android全屏製作Xamarin表格

我嘗試了以下操作,並且狀態欄上的所有控件都已隱藏,但狀態欄本身仍顯示出來。任何幫助,請

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; 

導航欄是隱藏的,但不是狀態欄。

回答

8

您可以通過在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); 
+0

謝謝。不要試圖將主要活動放在全屏模式下,只是一個Xamarin.Forms內容頁面,並且發現這個問題與主控細節導航有關。 – Paulus

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


     }