Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
ckrutsinger opened this issue Nov 19, 2024 · 3 comments
Labels
bug Something isn't working unverified

Comments

@ckrutsinger
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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

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 ckrutsinger added bug Something isn't working unverified labels Nov 19, 2024
@ramonB1996
Copy link

ramonB1996 commented Nov 25, 2024

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")));

@ckrutsinger
Copy link
Author

This used to work if I remember correctly.

Yes, this was working until a few weeks ago.

@codychaplin
Copy link

codychaplin commented Dec 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unverified
Projects
None yet
Development

No branches or pull requests

3 participants