I have created a Xamarin Forms project and i am unable to change my Android status bar color to transparent. I am changing my colors programmatically in the OnCreate() method of my MainActivity as follow:
  if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
        {
            Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            Window.SetStatusBarColor(Color.Transparent);
        }
I tried different colors and it's working fine but "Transparent" is not working at all. I am testing on an API 22.
My style.xml is as follow:
  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/blue</item>
    <item name="colorPrimaryDark">@color/blue</item>
    <item name="colorAccent">#FF4081</item>
    <item name="windowActionModeOverlay">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
If i set programmatically my color to Purple for example it will work without issue, but if I set it to Transparent, i will get my style.xml color which is blue. If i remove my style.xml ColorPrimaryDark color, i get a gray status bar. What could be the solution?
Did you try this ?
<item name="android:windowTranslucentStatus">true</item>
                        You can try adding this in styles.xml (Android proj)
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
   <item name="android:statusBarColor">@android:color/transparent</item>
   <item name="android:windowTranslucentStatus">true</item>
</style>
Looks something like this:-

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With