Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[BUG] StatusBarBehavior is causing Android layouts to go behind status bar and navigation bar buttons on launch

Open ckrutsinger opened this issue 1 year ago • 6 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

  • [x] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

Current Behavior

On an Android device, if I add

    <Shell.Behaviors>
        <xct:StatusBarBehavior StatusBarStyle="LightContent"/>
    </Shell.Behaviors>

then the first page displayed by the app will have the TitleView behind the phone's status bar and the bottom elements behind the Android navigation bar. In the repro app, the TabBar tabs are behind the Android navigation bar making them inaccessible for clicking.

Image

Not able to reproduce on iOS. No other platforms tested.

Expected Behavior

Expected behavior is to position the TitleView below the status bar and the bottom of the ContentPage should be above the Android navigation bar.

Image

Steps To Reproduce

  1. Run the repro app.
  2. You will immediately see that the layouts are not sized correctly.

Link to public reproduction project repository

https://github.com/ckrutsinger/StatusBarBehaviorBug

Environment

- .NET MAUI CommunityToolkit: 9.1.1
- OS: Android 11+
- .NET MAUI: 8.0.100

Anything else?

Appears that the StatusBarBehavior is causing the screens to receive the wrong sizing frame during layout.

ckrutsinger avatar Nov 19 '24 17:11 ckrutsinger

I second this. Happens on all my Android devices, phone & tablet.

This used to work if I remember correctly.

EDIT: Temporary workaround for this issue is, setting the statusbarcolor in your MainActivity.cs .OnCreate() method:

Window.SetStatusBarColor(ColorExtensions.ToAndroid(Color.FromArgb("#FF000000")));

ramonB1996 avatar Nov 25 '24 11:11 ramonB1996

This used to work if I remember correctly.

Yes, this was working until a few weeks ago.

ckrutsinger avatar Nov 25 '24 20:11 ckrutsinger

Can confirm something in 9.0.3 caused this as it was working for me in 9.0.2 and below. My workaround was to set the StatusBarColor, meaning it only breaks when it's not explicitly set. I changed: <toolkit:StatusBarBehavior StatusBarStyle="{AppThemeBinding Light='DarkContent', Dark='LightContent'}" /> to: <toolkit:StatusBarBehavior StatusBarColor="{AppThemeBinding Light=White, Dark=Black}" StatusBarStyle="{AppThemeBinding Light='DarkContent', Dark='LightContent'}" /> and it worked again.

codychaplin avatar Dec 16 '24 01:12 codychaplin

Looks like this is still occurring even in version 11.0.0

dbeckerton94 avatar Jan 22 '25 11:01 dbeckerton94

Looks like this is still occurring even in version 11.0.0

Update: 11.2.0 is still occurring 😭😭😭