[BUG] StatusBarBehavior is causing Android layouts to go behind status bar and navigation bar buttons on launch
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.
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.
Steps To Reproduce
- Run the repro app.
- 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.
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")));
This used to work if I remember correctly.
Yes, this was working until a few weeks ago.
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.
Looks like this is still occurring even in version 11.0.0
Looks like this is still occurring even in version 11.0.0
Update: 11.2.0 is still occurring 😭😭😭