[BUG] StatusBarBehavior transparent background when using .net maui shell
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
Using the StatusBarBehavior I can successfully set any backgroundcolor on Android and IOS when using the .net maui shell. When I try to set a transparent background, the statusbars background color is white instead of transparent. This happens regardless of setting the Shell.NavBarIsVisible true or false.
Expected Behavior
The background of the status bar should be transparent. This works well when not using .net maui shell (for navigation).
Steps To Reproduce
- Open the .net maui toolkit sample app
- Change the StatusBarColor of the behavior to transaprent on the related sample page
- Disable Shell.NavBarIsVisible on the page
- Add some demo content inside the scrollview
Link to public reproduction project repository
https://github.com/FM1973/RefreshGridRepo.git
Environment
- .NET MAUI CommunityToolkit:5.0.0
- OS:Android 11-13, IOS 14.x +
- .NET MAUI: 7.0.59
Anything else?
No response
Hi @FM1973. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Here ist the link to the repo: https://github.com/FM1973/RefreshGridRepo.git
Start the app and click on the button "Scrollview inside refreshview Android".
Workaround for anyone that is interested (I am unsure if this works for AppShell, but works for other type of navigation pattern)
In your MauiProgram.cs you can play around with the WindowManagerFlags for Android:
.ConfigureLifecycleEvents(events =>
{
#if ANDROID
events.AddAndroid(android => android.OnCreate((activity, bundle) => MakeStatusBarTranslucent(activity)));
static void MakeStatusBarTranslucent(Android.App.Activity activity)
{
activity.Window.SetFlags(Android.Views.WindowManagerFlags.TranslucentStatus, Android.Views.WindowManagerFlags.TranslucentStatus);
}
#endif
})