Fullscreen and no navigation bar

Hello, I am new to android development with xamarin. I want to create a simple game and feel like the best way to play a game on a smartphone is to have landscape orientation and completely fullscreen mode(no title or navigation bar). Landscape and no title bar was fairly easy to find info about, but not the navigation bar. I have tried to change theme a lot but nothing removed the navigation bar. Ex: android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen"

I know about the immersive and immersive sticky, but I have not been able to apply those to my android app using xamarin and all the code I could find from the xamarin webpage was very complex and I could not get it to work without errors.

Summary: I need help removing the "navigation bar"(back button, home button, etc.). Any help at all is very appreciated.


  • YkshLeoYkshLeo USMember ✭✭✭✭


    Try something like this :

    View decorView = Window.DecorView;
    decorView.SystemUiVisibility = SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen;
  • This game me an error "SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen;"
    "Cannot implicitly convert type 'Android.Views.SystemUiFlags' to 'Android.Views.StatusBarVisibility'. An explicit conversion exists(are you missing a cast?)"

  • YanFengYanFeng USMember

    I have encountered the same problem, you solve it?

  • YkshLeoYkshLeo USMember ✭✭✭✭

    @SimonBerglund, @YanFeng,

    Try something like this :

    View decorView = Window.DecorView;
    var uiOptions = (int)decorView.SystemUiVisibility;
    var newUiOptions = (int)uiOptions;
    newUiOptions |= (int)SystemUiFlags.Fullscreen;
    newUiOptions |= (int)SystemUiFlags.HideNavigation;
  • FrancescoFrancesco USMember ✭✭
    edited April 2018

    We're on the right track but, according with theese:


    we need to brute force a little more. Here we have a Global listener:

    `public class OnGlobalLayoutListener : Java.Lang.Object, IOnGlobalLayoutListener

        private int mScreenheight;
        private View mDecorView;
        public OnGlobalLayoutListener(int mioScreenheight, View mioDecorView)
            mScreenheight = mioScreenheight;
            mDecorView = mioDecorView;
        public void OnGlobalLayout()
            Rect r = new Rect();
            var keypadHeight = mScreenheight - r.Bottom;
            if (keypadHeight <= mScreenheight * 0.15)
                var uiOptions =
                    SystemUiFlags.HideNavigation |
                    SystemUiFlags.LayoutFullscreen |
                    SystemUiFlags.Fullscreen |
                mDecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;

    and then we can use it on any activity:

    `SetContentView (Resource.Layout.Main);

            TableLayout vista = FindViewById<TableLayout>(Resource.Id.main);
            int altezza_schermo = vista.Height;
            View decorView = Window.DecorView;
            vista.ViewTreeObserver.AddOnGlobalLayoutListener(new OnGlobalLayoutListener(altezza_schermo, decorView));`
Sign In or Register to comment.