Search code examples
androidxamarin.formsfullscreenstatusbar

xamarin.forms/droid: hide status bar, contentpage don't resize to fullscreen


I'm able to hide the Status bar in xamarin.droid with no problems.

Also I can hide it with xamarin.forms, but there the ContentPage will not resize to Fullscreen, so that I also have a colored bar without text at the top (in my screenshots the red bar).

I try several Things, e.g. this:

    public void HideStatusBar()
    {
        var activity = (Activity)Forms.Context;
        var window = activity.Window;
        var attrs = window.Attributes;
        attrs.Flags |= Android.Views.WindowManagerFlags.Fullscreen;
        window.Attributes = attrs;

        window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);
        window.AddFlags(WindowManagerFlags.Fullscreen);

        var decorView = window.DecorView;

        var uiOptions =
            (int)Android.Views.SystemUiFlags.LayoutStable |
            (int)Android.Views.SystemUiFlags.LayoutHideNavigation |
            (int)Android.Views.SystemUiFlags.LayoutFullscreen |
            (int)Android.Views.SystemUiFlags.HideNavigation |
            (int)Android.Views.SystemUiFlags.Fullscreen |
            (int)Android.Views.SystemUiFlags.Immersive;

        decorView.SystemUiVisibility = (Android.Views.StatusBarVisibility)uiOptions;

        window.DecorView.SystemUiVisibility = StatusBarVisibility.Hidden;
    }

screenshot with status

screenshot without status

I'm developing with visualstudio 2017, win10, latest xamarin.

Best regards and thanks a lot for your answer! And sorry in advance if this is a duplicate question, but my last 2h search didn't get any answer.

Thies


Solution

  • Now I was really amazed. An update for xamarin.forms has been available, current is now 2.3.4.224. And guess what: Status bar disappeared as it should!

    Looks like a nice accident! Anyway, thanks a lot...