Android通知图标是一个白色圆圈

Pou*_*lsQ 7 notifications icons android

我今天的通知图标出现了一个奇怪的问题。

看起来像这样: 在此处输入图片说明 (白圈...)

我做了不好的事吗?

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);
Run Code Online (Sandbox Code Playgroud)

这里是我的图标图像(从这里下载的最新https://material.io/icons/#ic_photo): http://image.noelshack.com/fichiers/2016/44/1478185219-icon-notification.png

我错过了什么 ?

作为记录,我使用的是SDK 24,目前仅创建了hdpi资源文件夹。

编辑#1:我已经添加了ldpimdpi并且xhdpi图标,没有什么变化?

编辑#2:为了更精确,我正在尝试从服务... FCM消息传递服务...创建此通知。

Aji*_*K P 8

如果您的 compileSDKversion 高于 20,则通知图标应该是透明背景上的白色图像。否则图像将呈现为白色图像。

请也通过以下链接获取创建图标的指南

https://www.google.com/design/spec/patterns/notifications.html

以及通知图标生成器。

https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.space.trim=1&source.space.pad=0&name=ic_stat_example


inl*_*cou 6

您必须使用没有背景的通知图标。Android 将添加圆形背景。

You can set background color with

.setColor(context.getResources().getColor(R.color.colorPrimary))

to match your app indentity.

Icon inside will remain white and circle will get the color you defined.

在 Android Studio 上 在系统栏 通知时


Pou*_*lsQ 3

这似乎是编译期间缓存的问题...我使用的第一个图像很糟糕(全彩色),所以我认为我的编译器在文件名上创建了某种缓存。

我在 Windows 上工作并执行了以下操作:从手机中卸载应用程序,使 Android sudio 中的所有缓存无效 => 重新编译时,图标正常。