[英]Color of Notification Icon in android
有时,当我在Moto E上升级到lolipop时,小通知图标变成了黑白(我读到它是新的Google指导原则)。 好吧,我可以忍受。 现在,我注意到该图标再次变色了,并且我没有更改代码并一直使用相同的drawable。 它肯定是显示黑白的,现在是彩色的。 我的设备在Android 5.0.2上也:
compileSdkVersion 22
buildToolsVersion "22.0.1"
targetSdkVersion 22
这是我的代码:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
this)
.setVibrate(new long[] { 10, 10, 10, 10, 10 })
.setSound(alarmSound)
.setSmallIcon(R.drawable.logo)
.setContentTitle(title)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg);
谁能告诉我这是怎么发生的?
似乎自从android升级到lolipop以来,通知上的小图标就只有黑白...
但是可以使用.setColor()
方法更改它,如下面的代码所示。
这是设置通知图标颜色的代码:-
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notificationBuilder.setSmallIcon(R.drawable.appypie_small);
notificationBuilder.setColor(getResources().getColor(R.color.notification_color));
}
else {
notificationBuilder.setSmallIcon(R.drawable.appypie_small);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.