I have a Xamarin.Forms app being built for iOS and Android.
I'm having some difficulty in Android updating the icon colors when setting the status bar color. I have this working for API levels below 30 using the following code:
var isLight = false;
Window currentWindow = Platform.CurrentActivity.Window;
if (Color.FromHex(hexColor).Luminosity > 0.5)
{
isLight = true;
}
currentWindow.SetStatusBarColor(androidColor);
currentWindow.DecorView.SystemUiVisibility = isLight ? (StatusBarVisibility)(SystemUiFlags.LightStatusBar) : 0;
From what I can tell, DecorView.SystemUiVisibility is deprecated in API 30, and is supposed to be replaced with window.insetsController
What I can't figure out is if/where this API is exposed in Xamarin for me to use.
I looked at this SO question: How to change the status bar color without a navigation page
and following the last answer, I attempted to use:
var lightStatusBars = isLight ? WindowInsetsControllerAppearance.LightStatusBars : 0;
currentWindow.InsetsController?.SetSystemBarsAppearance((int)lightStatusBars, (int)lightStatusBars);
but it will not build, saying Window doesn't have InsetsController
Has anyone figured this out? I definitely need to support the latest Android and this feature is killing me
Thanks in advance!