首先,我已经经历了几个讨论此主题的论坛。例如:Android Push Notifications: Icon not displaying in notification, white square shown instead
如果将ic_launcher徽标作为小图标添加到通知中,则在运行该应用程序时会看到它。但是,如果我尝试将自定义图片(.png)文件添加为徽标,则会看到全白图片。
我不了解透明图像/徽标的概念。在许多论坛中,这被认为是空白图像的原因。 如果确实如此,那么我该如何生成可显示的自定义透明图像?请注意,我使用的图像与我的启动徽标[清单文件内]相同,并且按预期工作。
我的通知对象如下:
notificationBuilder.setOngoing(true)
.setSmallIcon(R.mipmap.ic_custom_image_icon)
.setContentTitle("My-Title")
.setPriority(NotificationManager.IMPORTANCE_MIN)
.setCategory(Notification.CATEGORY_SERVICE)
.setStyle(new NotificationCompat.DecoratedMediaCustomViewStyle()
.setMediaSession(new MediaSessionCompat(this.getApplication(), MY_TAG).getSessionToken()))
.setColor(0x169AB9)
.setWhen(System.currentTimeMillis())
.setOnlyAlertOnce(true)
.setColorized(true);
答案 0 :(得分:0)
怀疑,自定义图像必须具有透明背景。为了实现这一目标,可以利用在线转换器。打开具有透明背景的图像作为图像资源(在R.drawable下),该图像非常适合用作小图标。