Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change status bar text color when primaryDark is white

I am trying to reproduce the behaviour of Google Calendar application: enter image description here

but I have not found a way to change the status text color. If i set the colorPrimaryDark as white I cannot see the icons neither text of status bar due their color is white as well.

Is there any way to change the status bar text color?

like image 649
MarcForn Avatar asked Jul 14 '16 19:07

MarcForn


People also ask

How do I change the color of my status bar text?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.

How do I make the status bar icon color white in flutter?

Step 1: Locate the MaterialApp widget. Step 2: Inside the MaterialApp, add the theme parameter with ThemeData class assigned. Step 3: Inside the ThemeData add the appBarTheme parameter and then assign the AppBarTheme class. Step 4: Inside the AppBarTheme , specify the systemOverlayStyle parameter and set the color.


2 Answers

I'm not sure what API level your trying to target, but if you can use API 23 specific stuff, you can add the following to your AppTheme styles.xml:

<item name="android:statusBarColor">@color/colorPrimaryDark</item> <item name="android:windowLightStatusBar">true</item> 

when android:windowLightStatusBar is set to true, status bar text color will be able to be seen when the status bar color is white, and vice-versa when android:windowLightStatusBar is set to false, status bar text color will be designed to be seen when the status bar color is dark.

Example:

<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">     <!-- Customize your theme here. -->     <item name="colorPrimary">@color/colorPrimary</item>     <item name="colorPrimaryDark">@color/colorPrimaryDark</item>     <item name="colorAccent">@color/colorAccent</item>     <!-- Status bar stuff. -->     <item name="android:statusBarColor">@color/colorPrimaryDark</item>     <item name="android:windowLightStatusBar">true</item>  </style> 
like image 110
Jon Avatar answered Sep 22 '22 12:09

Jon


you can do that programmatically like this answer

just add this

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); 
like image 34
Mycoola Avatar answered Sep 21 '22 12:09

Mycoola