首页 > 解决方案 > Flutter:通知图标显示白色圆圈

问题描述

我已经尝试了一切,包括清单文件的更改以及将图标属性放在通知功能中,但通知图标仍然是白色圆圈!我的图标颜色为白色,背景透明,使用https://romannurik.github.io/AndroidAssetStudio/icons-notification.html#source.type=clipart&source.clipart=ac_unit&source.space.trim=1&source.space.pad= 0&name=ic_stat_ac_unit

我的清单文件如下所示:在此处输入图像描述

         <meta-data
         android:name="com.google.firebase.messaging.default_notification_icon"
         android:resource="@drawable/notification_icon" />

         <meta-data
        android:name="com.google.firebase.messaging.default_notification_color"
        android:resource="@color/colorPrimary" />

我已经包含了我的文件夹结构的图片!我到底错过了什么?在此处输入图像描述

标签: androidfirebaseflutterpush-notification

解决方案


  1. 尝试下载、解压缩并粘贴 res 文件夹中的所有可绘制文件夹,而不是 res 文件夹中的 .png 图像。即drawable,drawable-hdpi等。 可绘制文件夹

  2. 如果要更改图标的颜色,请在通知图标标签后添加元数据标签

转到“android\app\src\main\res\values”并添加一个 colors.xml 文件在其中添加颜色:

<color name="colorAccent">#00FF00</color>

颜色.xml

我也遇到过这个问题,并在 Github 上分享了我的解决方案。 flutter_notification_icon_issue

万一,这对你不起作用,我建议使用他们提供的现有剪贴画在 Android Asset Studio 中创建一个不同的图标并尝试一次。只是为了确保您创建的图标不是问题的原因。


推荐阅读