Hello,
Is there a better way to change this color?
No, it is the easiest way to change the color of status bar of android in MAUI.
Is there a way to force the battery level, the clock in black to see them even when the background is white?
Yes, you can change the color of battery level to grey (Native Android only allow to set grey or white).
Please open your MainActivity.cs
, override OnCreate
method.
For Android 11 or later, please use WindowInsetsController to set SystemBarsAppearance change the battery level color.
if (Build.VERSION.SdkInt >= BuildVersionCodes.R)
{
Window.InsetsController?.SetSystemBarsAppearance((int)WindowInsetsControllerAppearance.LightStatusBars, (int)WindowInsetsControllerAppearance.LightStatusBars);
}
For Android 6 to android 10, please use set SystemUiVisibility to change it.
if(Build.VERSION.SdkInt >= BuildVersionCodes.M && Build.VERSION.SdkInt < BuildVersionCodes.R)
{
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.LightStatusBar;
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.