我升级了Android 6.0,但我的应用程序出现了问题。当状态栏背景颜色不是白色时,通知图标看起来很好。 (通知图标PNG只有白色和透明度) 但是,如果某些应用程序将背景颜色更改为白色,则我的通知图标不会反转为黑色。如何在其他应用程序将状态栏背景颜色设置为白色时将白色通知图标反转为黑色? (我不是在问如何使用彩色图标。) 下面的图片显示了一个问题。
通知构建代码:
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
->values-v23/styles.xml
<style name="AppTheme" parent="android:Theme.Material.NoActionBar">
</style>
找到解决方案
我将通知图标添加到drawable目录而不是drawable-*dpi目录中。现在它可以正常工作了。