繁体   English   中英

Android 通知有一个彩色图标,而不是变成白色

[英]Android notification has a color icon instead of being turned white

我的 Android 应用使用 Firebase Cloud Messaging 进行通知。 当收到通知时,图标不会像其他图标那样变成白色。

在此处输入图像描述

我正在使用targetSdkVersion 23

我的清单中有这个:

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

android/app/src/main/res/drawable/notification_icon.png有一个 PNG 文件。

如何让图标正常运行?

看一下SVG设计器中的图标。 您是否已为其指定颜色或在此处显示白色?

正如Will Jones所建议的那样,解决方案是使用SVG文件,并使用以下文件将其转换为XML: http : //inloop.github.io/svg2android/ 然后,我将文件复制到android/app/src/main/res/drawable/notification_icon.xml并删除了旧的PNG文件。

图标现在可以正确呈现。

试试这个

然后将您的资源设置为白色:android:resource =“ @ color / google_white”

一种选择是使用通知图标生成器

我来晚了,但是尝试将其添加到您的清单中

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

就我而言,我有一个离子项目,所以@Flavien的答案是正确的,但不是:

android/app/src/main/res/drawable/notification_icon.xml

您需要在没有 .xml 后缀的情况下编写,如下所示:

android/app/src/main/res/drawable/notification_icon

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM