Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[BUG] StatusBarBehavior transparent background when using .net maui shell

Open FM1973 opened this issue 2 years ago • 3 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

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

  1. Open the .net maui toolkit sample app
  2. Change the StatusBarColor of the behavior to transaprent on the related sample page
  3. Disable Shell.NavBarIsVisible on the page
  4. 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

FM1973 avatar Mar 27 '23 16:03 FM1973

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.

ghost avatar Mar 27 '23 19:03 ghost

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".

FM1973 avatar Mar 28 '23 06:03 FM1973

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
                 })
                 

ramonB1996 avatar Oct 19 '23 15:10 ramonB1996