Jiy*_*Kim 13 notifications icons android colors
我升级了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());
Run Code Online (Sandbox Code Playgroud)值-V23/styles.xml
<style name="AppTheme" parent="android:Theme.Material.NoActionBar">
</style>
Run Code Online (Sandbox Code Playgroud)**找到解决方案**
我在drawable目录中添加了通知图标而不是drawable-*dpi.现在它正在运作.
Nob*_*dy8 11
回答已经很晚了,但对于那些有同样问题的人来说,
我也有这个问题,我发现问题出在图形图标上.您可以使用此在线工具解决问题.打开这个链接:
选择您的图像(具有大尺寸),下载资源并将其复制到您的项目中.
最后使用设置通知图标 .setSmallIcon(R.drawable.ICON_NEW_NAME)
希望这可以帮助
我认为问题出在android 5.0或更高版本的设备上。
https://developer.android.com/design/patterns/notifications.html
https://developer.android.com/about/versions/android-5.0-changes.html
这是一个解决方案:
Notification notification = new Notification.Builder(context)
.setAutoCancel(true)
.setContentTitle("My notification")
.setContentText("Look, white in Lollipop, else color!")
.setSmallIcon(getNotificationIcon())
.build();
return notification;
Run Code Online (Sandbox Code Playgroud)
和方法getNotificationIcon():
private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP);
return useWhiteIcon ? R.drawable.icon_black : R.drawable.ic_nomarl;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12747 次 |
| 最近记录: |