我正在尝试设置使用 Android Image Asset 生成的通知图标。生成的图像只有白色和一些透明部分。
我在这里粘贴了一段代码。这与我在代码中设置的颜色不同。 看我的代码。如果可能的话请提供解决方案。
我的代码如下所示:
Notification inboxStyleNotification = new NotificationCompat.Builder(MyFcmListenerService.this)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(R.drawable.noti_status_icon)
.setLargeIcon(anImage)
.setPriority(Notification.PRIORITY_HIGH)
.setContentIntent(pIntent)
.setChannelId(transactions_chnl_id)
.setCategory(Notification.CATEGORY_MESSAGE)
.setColor(getResources().getColor(R.color.yellow_light))
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setStyle(inboxStyle)
.setAutoCancel(true)
.build();
yellow_light 代码是:
#FFC107
但是当它以 R.drawable.noti_status_icon
反射时,它不会以准确的 yellow_light
颜色反射。
如何做到这一点?
首先,删除这部分代码
.setLargeIcon(anImage)
.setStyle(inboxStyle)
然后生成一个像这样的通知图标,选择一个图像,在那里设置黄色,单击下一步,完成。它将生成一个黄色图标,图标名称为 noti_status_icon。
然后使用下面的代码
Notification inboxStyleNotification = new NotificationCompat.Builder(MyFcmListenerService.this)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(R.drawable.noti_status_icon)
.setPriority(Notification.PRIORITY_HIGH)
.setContentIntent(pIntent)
.setChannelId(transactions_chnl_id)
.setCategory(Notification.CATEGORY_MESSAGE)
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI)
.setAutoCancel(true)
.build();