Reputation: 5830
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?
Upvotes: 1
Views: 5424
Reputation: 91
Not since Lollipop. Starting with Android 5.0, the guidelines say:
Notification icons must be entirely white. Even if they're not, the system will only consider the alpha channel of your icon, rendering them white
The only way to have a coloured icon on Lollipop is to lower your targetSdkVersion to values <21.
If you still however decide you want colored icons, you could use the DrawableCompat.setTint method from the new v4 support library.
Upvotes: 3
Reputation: 5020
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>
Upvotes: 3