为什么在Android Lollipop中使用Notification.Builder.setSmallIcon设置的图标显示为白色方块?

Bor*_*rja 62 notifications android android-notification-bar android-5.0-lollipop

我有这个代码:

Notification notif;

// Build notification
Notification.Builder notifBuilder = new Notification.Builder(context);
notifBuilder.setContentIntent(pendingIntent);
notifBuilder.setContentTitle(title);
notifBuilder.setSmallIcon(icon_resId);
notifBuilder.setContentText(ne.getCaption());
notifBuilder.setDefaults(Notification.DEFAULT_ALL);
notifBuilder.setAutoCancel(autocancel);
notifBuilder.setWhen(System.currentTimeMillis());
notif = notifBuilder.build();
Run Code Online (Sandbox Code Playgroud)

在Android 4.4中运行良好.

但是,在Android 5.0中,状态栏中显示的图标是白色方块.设备锁定时显示的新"通知正文"中显示的图标是正确的.

http://developer.android.com/reference/android/app/Notification.Builder.html中,我没有看到有关API级别21的通知图标的任何新内容

por*_*cus 31

查看文档:http: //developer.android.com/design/style/iconography.html

有句话:"通知图标必须完全是白色的.此外,系统可能会缩小和/或使图标变暗."

  • 文档已更改:https://www.google.com/design/spec/patterns/notifications.html"不透明白色,仅使用Alpha通道." (4认同)
  • porlicus或Ben的链接目前都没有说明小图标的规格. (4认同)

Bor*_*rja 29

我已经解决了将图标大小更改为16x16像素并仅使用白色的问题

  • 您没有注意到棒棒糖中的所有通知都被屏蔽为白色?为了在棒棒糖中使用好的图标,你应该使用一个具有明显形状的图标.所有颜色都将转换为白色,因此透明度是必须的. (3认同)