Forum Xamarin.Forms

Edit styles.xml in C#

Hello everybody!

I have the following problem. I want to change the color of the status bar on Android in code. (The top bar that shows the time, battery, etc.). I know that I can change the background color of the bar in styles.xml in the Android project as follows:

 <item name = "colorPrimaryDark"> # ffffff </item>

And I can switch the text color between black and white as follows:

 <item name = "android: windowLightStatusBar"> true </item>

But how can I set these values in C # without the styles.xml?

Answers

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    In the Android project, you can call Window.SetStatusBarColor(color); in the Activity code at least.

  • SymxnSymxn Member

    Thank you!
    But is there a way to access and set every single property in styles.xml with C#?

  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    I would say that if you can find a way to do it in Java, you can find a way to do it in C#.

    Sadly I think there are some things that just can't be done outside of the styles.xml, but the list isn't too large as far as I know.

Sign In or Register to comment.