Modify Android statusbar on the launch of an app with xamarin

yccycc USMember ✭✭

Hi,

I post again my previous questions, it seem's that i have delete it by mistake.

I have a Xamarin application and i have the color of my status bar who changer with the launch of the app from black to blue.

So i have tried to set the color of the status bar on the start of the application and not after a loading.

Actually my code is :

namespace StatusBar.Droid
{
    [Activity(Label = "StatusBar.Android", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, Theme = "@style/StatusBar.SplashScreen")]
    public class SplashActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            Window.SetStatusBarColor(Color.ParseColor("#0D4680"));

            StartActivity(typeof(MainActivity));
        }
    }
}

I also have a styles.xml in the values-v21 folder :

<style name="StatusBar.SplashScreen" parent="@android:style/Theme.Material.Light">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  </style>

And my color are set on a color.xml file on the same folder :

<resources>
  <color name="colorPrimary">#0d4680</color>
  <color name="colorPrimaryDark">#0d4680</color>
  <color name="colorAccent">#0d4680</color>
</resources>

So my question is, can i force the app to set the color of the status bar on the start ?

Thank for your help.

Posts

  • yccycc USMember ✭✭

    This post can be delete because of multi post

Sign In or Register to comment.