How do I change the color of the bar status icons in Material Design

Asked

Viewed 1,144 times

4

I need to change icon colors equal to app of Google Agenda, as shown in the image below:

Aplicativo Google Agenda inserir a descrição da imagem aqui

I saw that in Material Design you have the options colorPrimaryDark but you don’t have to change the color of the icons. Someone can help me?

1 answer

8


Just you define how true the property windowLightStatusBar in the style inside the file styles.xml. This way, icons will be changed to gray (no custom colors). See:

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

Note: This only works from the API 23. For example: values-v23/styles.xml. Or you can enter the property targetApi being like 23 in this way:

<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>

Roman Nurik Google+ post

Picture of Roman Nurik Google+ post

It is also possible to do this programmatically, see:

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 {
        decor.setSystemUiVisibility(0);
    }
}

Note that you first need to check the SDK version you are using.

  • perfect Ack Lay, I’ll check.

  • It worked perfectly, but would have some option to set the color of the icons instead of the gray pattern ?

  • @afnascimento only Ligth and dark by what I’ve read. I think too much customization is bad, because it ends up leaving too much of the pattern.

  • Roger @Acklay, thanks for your help

  • How do I validate ? obg

Browser other questions tagged

You are not signed in. Login or sign up in order to post.