【发布时间】:2016-08-29 07:08:55
【问题描述】:
我升级了 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。现在它正在工作。
【问题讨论】:
-
看看这个post。另请阅读此documentation。希望你能得到一个线索。干杯.... :)
-
@verbose 我已经阅读过,但会再次检查。谢谢
-
我尝试了您的解决方案,但它对我不起作用。
-
我希望你考虑将你的解决方案从问题复制到答案,它只是解决了我的问题,而这个问题的答案没有,但我看到你写的纯粹是运气。我本可以只是路过,找不到合适的答案,然后关闭您的问题,尽管它已经包含我需要的内容。
标签: android colors notifications icons