[英]Change Android small notification icon color depending on context
首先,我們應該使用NotificationCompat.Builder
其次,這是獲取該行為的代碼
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, "NOTIFICATION_CHANNEL_NAME")
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle(title)
.setContentText(message)
.setColor(ContextCompat.getColor(context, R.color.your_color))
.setContentIntent(pendingIntent);
還有一件事 ,你正在使用的圖標( R.drawable.notification_icon
)應該是白色的,並且應該有一點不透明度( 它應該只是有點透明 )。 之后,您的頂部通知圖標將為白色,當您繪制通知時,它將變為R.color.your_color
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.