本文介绍了Android 状态栏图标颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以更改状态栏图标的颜色(不是状态栏的颜色,colorPrimaryDark)假设我想要这个状态栏:

I was wondering if it's possible to change the statusbar icons colour (not the statusbar colour, colorPrimaryDark)Let's say I want this statusbar with:
<item name="colorPrimaryDark">@android:color/white</item>

还有黑色的图标,可以吗?

and the icons in black, is it possible?

谢谢.

M 开发者预览版中的新功能:windowLightStatusBar.翻转这个在您的主题中告诉系统使用深色前景,对于颜色较浅的状态栏.注意 M 预览似乎有一个错误通知图标保持白色,而系统状态图标正确更改为半透明黑色.

来自:Roman Nurik Google+

from: Roman Nurik Google+ post

推荐答案

自从 Lollipop 之后就没有了.从 Android 5.0 开始,指南说:

Not since Lollipop. Starting with Android 5.0, the guidelines say:

通知图标必须完全为白色.

即使不是,系统也只会考虑图标的 Alpha 通道,将它们呈现为白色

Even if they're not, the system will only consider the alpha channel of your icon, rendering them white

在 Lollipop 上使用彩色图标的唯一方法是将您的 targetSdkVersion 降低到值 <21,但我认为您最好遵循指导方针和仅使用白色图标.

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

如果您仍然决定需要彩色图标,则可以使用 DrawableCompat.setTint 方法来自新的 v4 支持库.

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

这篇关于Android 状态栏图标颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 23:48