我今天的通知图标遇到了一个奇怪的问题。
我是不是做了什么坏事?
Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon_notification)
.setContentTitle(this.getString(R.string.notification_title))
.setContentText(this.getString(R.string.notification_text))
.setAutoCancel(true)
.setSound(defaultSoundUri)
.setContentIntent(pendingIntent);
这是我的图标图像(从这里新鲜下载https://material.io/icons/#ic_photo): http://image.noelshack.com/fichiers/2016/44/1478185219-icon-notification.png
我错过了什么吗?
郑重声明,我使用的是 SDK 24,并且目前仅创建了 hdpi
资源文件夹。
编辑 #1:我添加了 ldpi
、mdpi
和 xhdpi
图标,没有任何变化...
编辑 #2:为了更精确,我正在尝试从服务创建此通知...FCM 消息服务...
最佳答案
如果您的compileSDK版本高于20,则通知图标应该是透明背景图像上的白色。否则图像将呈现为白色图像。
请也通过以下链接获取创建图标的指南
https://www.google.com/design/spec/patterns/notifications.html
还有通知图标生成器。
关于Android 通知图标是一个白色圆圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40404916/