Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

Safe area doesn't work on Shell in Android

Open luczha opened this issue 5 years ago • 5 comments

I'm working on Shell in xamarin.forms . Now I want to let the status bar be transparent in Android . I try to implement it by invoking the line

Window.AddFlags(WindowManagerFlags.TranslucentStatus);

It works as expected in normal ContentPage .

glxbhrx9ui9n

However , in Shell it doesn't work .

demo (2) .

If I miss something important or it is an existing issue in Shell ?

luczha avatar Aug 18 '20 07:08 luczha

@luczha The Shell issue image is not loading, could you update it?. Or better, could you attach a small sample where reproduce your issue and check the code?

jsuarezruiz avatar Aug 24 '20 15:08 jsuarezruiz

do we have news?

Jorgo78 avatar Feb 17 '21 17:02 Jorgo78

private void HideActionBar() { Window.AddFlags(WindowManagerFlags.Fullscreen); Window.AddFlags(WindowManagerFlags.KeepScreenOn);

        int uiOptions = (int)Window.DecorView.SystemUiVisibility;
        uiOptions |= (int)SystemUiFlags.LowProfile;
        uiOptions |= (int)SystemUiFlags.Fullscreen;
        uiOptions |= (int)SystemUiFlags.HideNavigation;
        uiOptions |= (int)SystemUiFlags.Immersive;
        uiOptions |= (int)SystemUiFlags.ImmersiveSticky;
        uiOptions |= (int)SystemUiFlags.LayoutFullscreen;
        uiOptions |= (int)SystemUiFlags.LayoutHideNavigation;

        Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;
    }

protected override void OnCreate(Bundle savedInstanceState) { HideActionBar(); Window.DecorView.SystemUiVisibilityChange += (sender, e) => HideActionBar(); }

protected override void OnResume() {

        HideActionBar();
    }

this worked for me

Jorgo78 avatar Feb 24 '21 15:02 Jorgo78

cc @PureWeen

rachelkang avatar Apr 28 '21 18:04 rachelkang

Not sure the time line on addressing this issue on 5.0

One thing you can try is to explicitly implement this interface on your page https://github.com/xamarin/Xamarin.Forms/blob/caab66bcf9614aca0c0805d560a34e176d196e17/Xamarin.Forms.Core/IPageController.cs#L7

And then return the content area with a zero x position

That might adjust the content vertically.

My other recommendation for finding a workaround would be to use the Android Layout Inspector to see what native view is shifted down and then you can use a custom renderer or a custom layout to adjust the positioning.

PureWeen avatar May 07 '21 14:05 PureWeen