我使用 NotificationBuilder 为 android 创建了通知,即使我设置了 .setColor(),它也会忽略颜色并将小图标的背景颜色设置为黑色。我的目标 SDK 是 23,最小 SDK 是 19。我用于调试的手机有 Android Marshmallow。感谢您的帮助。
.setContentTitle(msgTitle)
.setSmallIcon(R.mipmap.notification_icon)
.setColor(R.color.ColorPrime) // ColorPrime is red.
.setLargeIcon(msgIcon)
.setTicker(msgBody)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msgBody).setBigContentTitle(msgTitle))
.setContentText(msgBody)
.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
.setPriority(Notification.PRIORITY_HIGH);
最佳答案
解决了。
而不是 .setColor(R.color.ColorPrime)
使用 .setColor(getResources().getColor(R.color.ColorPrime))
完全有效。
关于Android通知小图标背景一直是黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37865918/