我升级了 android 6.0,我的应用程序有问题。
当状态栏背景颜色不是白色时,通知图标是好的。 (通知图标 png 只有白色和 alpha)
但如果某些应用程序将背景颜色更改为白色,我的通知图标不会反转为黑色。
当其他应用程序将状态栏背景颜色设置为白色时,如何将白色通知图标反转为黑色? (我不是说如何使用彩色图标。)
下图显示了一个问题。
通知构建代码
Notification.Builder mBuilder = new Notification.Builder(context) .setSmallIcon(R.drawable.ic_notifications_none) .setPriority(priority2) .setOngoing(true); mBuilder.setContent(generateMessageView(message)); Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mBuilder.setContentIntent(intent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
values-v23/styles.xml
<style name="AppTheme" parent="android:Theme.Material.NoActionBar"> </style>
找到解决方案
我将通知图标添加到 drawable 目录而不是 drawable-*dpi。现在可以使用了。
最佳答案
现在回答晚了,但对于其他有同样问题的人,
我也有这个问题,我发现问题出在图形图标上。 您可以使用此在线工具解决问题。 打开此链接:
选择你的图片(大尺寸),下载资源并将它们复制到你的项目中。
最后使用 .setSmallIcon(R.drawable.ICON_NEW_NAME)
设置通知图标
希望对你有帮助
关于当背景颜色为白色时,Android 通知图标颜色不会改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37017672/