Search code examples
androidcolorswindowiconsstatusbar

Android: Is it possible to change the color of icons in status bar in Android Lollipop


I have the following function that changes the color of the status bar:

   public static void colorStatusBar(Window window, Context context, boolean transparent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if(transparent){
            window.setStatusBarColor(context.getResources().getColor(android.R.color.transparent));
        }else{
            window.setStatusBarColor(context.getResources().getColor(R.color.timeline_unselected));
        }
    }
}

My problem is, it changes the status bar color, but not the icons color, which makes them nearly invisible. Example: http://postimg.org/image/ah01hzxdz/ Is it possible to change the icons colour too?


Solution

  • Yes it's possible to change it to gray (no custom colors) but this only works from API 23 and above you only need to add this in your values-v23/styles.xml into your theme declaration.

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