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

3

I need to change the colors of the icons the same as app in Google Calendar, as shown in the image below:

I saw that in Material Design you have the options colorPrimaryDark but you do not have to change the color of the icons. Can anyone help me?

    
asked by anonymous 07.03.2017 / 16:29

1 answer

7

Just set it to true windowLightStatusBar in style in of the styles.xml file. This will change the icons 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 this way:

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

ImageofRomanNurik Google+ post

You can also 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 version of the SDK you are using.

    
07.03.2017 / 16:39