Android status bar icon color

I was wondering if it is possible to change the icon icon <<< color, colorPrimaryDark ). enter image description here Let's say I want this status bar to be: <item name="colorPrimaryDark">@android:color/white</item>

and badges in black, is that possible?

Thank.

EDIT:

New in preview M: windowLightStatusBar. Turning it over, your topic says that the system uses a dark foreground, useful for lighter status bars. Please note that the preview M has an error where the notification icons remain white, and the system status icons correctly change to translucent black.

from: Roman Nurik Google+ post enter image description here

+46
android android-5.0-lollipop android-styles android-statusbar
May 6 '15 at 11:48
source share
4 answers

Not like Lollipop. Starting with Android 5.0, the manuals say:

Notification icons should be completely white.

Even if it’s not, the system will consider the alpha channel of your icon, making them white

Bypass

The only way to have a colored icon on Lollipop is to reduce targetSdkVersion to values <21 , but I think you better follow the guidelines and use only white icons.

If you still decide that you want colored icons, you can use the DrawableCompat.setTint method from the new v4 support library.

+15
May 6 '15 at 11:52
source share

Yes, you can change it to gray (without custom colors), but this only works with API 23 and above, you only need to add this to your values-v23 / styles.xml

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

enter image description here

+71
Nov 24 '15 at 13:23
source share

@eOnOe answered how we can change the hue of the status bar via xml. But we can also dynamically change it in code:

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { View decor = getWindow().getDecorView(); if (shouldChangeStatusBarTintToDark) { decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } else { // We want to change tint color to white again. // You can also record the flags in advance so that you can turn UI back completely if // you have set other flags before, such as translucent or full screen. decor.setSystemUiVisibility(0); } } 
+28
Jun 08 '16 at 6:06
source share

if the API level is less than 23 than you should use it that way. this worked for me, declaring it under v21 / style .

 <item name="colorPrimaryDark" tools:targetApi="23">@color/colorPrimary</item> <item name="android:windowLightStatusBar" tools:targetApi="23">true</item> 
+12
Dec 30 '16 at 4:45
source share



All Articles