SmallIcon颜色自动变为白色为什么在通知Android?
问题描述:
public void animatedNotification() {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(ic)
.setLights(Color.GREEN, 10000, 10000)
.setWhen(when)
.setPriority(Notification.PRIORITY_HIGH)
.setContentTitle(title)
.setContentText("Plants Need Watering Some of Your work is pending");
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// mId allows you to update the notification later on.
mNotificationManager.notify(0, mBuilder.build());
}
答
.setSmallIcon(android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP ? R.mipmap.ic_launcher : R.drawable.notification_icon_bw_xhdpi)
.setColor(ResourcesCompat.getColor(getResources(), R.color.primary, getTheme()))
使用颜色区分您的应用程序与其他人。通知图标应该只是透明背景图像。 (https://developer.android.com/design/patterns/notifications.html)
在lollypop之前,您可以对所有通知图标使用相同的mipmap图标。但是从棒棒糖开始,你需要创建新的通知图标(Silhoette种类的图标)。
当我更改背景时,整个通知将变为白色。 –
您需要为通知创建单独的图标,以便在白色背景上呈现良好。 – Ramesh
我在Eclipse上编写应用程序之前创建它,但现在我们在Android Studio上移动问题出现,.. –