7

Is there anyway to get my Xamarin Forms application on Android go fullscreen or immersive mode?

I tried the following, and all the controls on the status bar are hidden but the status bar itself is still showing. Any help, please

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;

The navigation bar is hidden but not the status bar.

poupou
  • 43,413
  • 6
  • 77
  • 174
PaulusHub
  • 385
  • 1
  • 4
  • 17

2 Answers2

12

You can do this by setting the theme in the Activity attribute:

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

Alternatively, if your only after a specific Activity being fullscreen, then set the following flags in the activities OnCreate method:

this.Window.AddFlags(WindowManagerFlags.Fullscreen);
this.Window.ClearFlags(WindowManagerFlags.Fullscreen);
KidCode
  • 3,990
  • 3
  • 20
  • 37
  • Thanks. Not trying to put the main activity in fullscreen mode just a Xamarin.Forms content page, and have found that problem to be with master-details navigation. – PaulusHub Jan 27 '16 at 19:26
  • @Paulus I think I ran into same issue. Master details navigation and the app is not full screen. What was your problem and how did you resolve it? – envyM6 May 05 '19 at 20:53
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);


        }
Ivan Voitovych
  • 126
  • 1
  • 6