Android - 通知图标颜色不受 setColor 影响
Android - Notification icon color not affected by setColor
我正在我的应用程序中显示通知。我希望状态栏中的小图标为白色,但通知本身为另一种颜色(绿色),如 .
中所述
我使用 72x72、纯白色、透明、RGB-gamma-color-space PNG 文件作为图标:
这是它在状态栏中的显示方式:
但它在通知本身中仍然是白色的(即使应用标题获得了正确的颜色):
这是我用来显示通知的代码:
using AndroidX.Core.App;
var builder = new NotificationCompat.Builder(this, "MY_CHANNEL")
.SetSmallIcon(Resource.Mipmap.ic_notification_alert)
.SetContentTitle("Test1")
.SetContentText("This is a test")
.SetColor(GetColor(Resource.Color.colorPrimary));
NotificationManagerCompat.From(this).Notify(777, builder.Build());
我已经尝试将图标移动到 drawable 文件夹、mipmap 文件夹并使用 中提到的工具。我正在安装 Android 8.0.0 的三星 Galaxy S7 上进行测试。我错过了什么?
将图标缩小到恰好 48x48 像素突然使正确的颜色出现。
我仍然不明白这种未记录的行为。
我正在我的应用程序中显示通知。我希望状态栏中的小图标为白色,但通知本身为另一种颜色(绿色),如
我使用 72x72、纯白色、透明、RGB-gamma-color-space PNG 文件作为图标:
这是它在状态栏中的显示方式:
但它在通知本身中仍然是白色的(即使应用标题获得了正确的颜色):
这是我用来显示通知的代码:
using AndroidX.Core.App;
var builder = new NotificationCompat.Builder(this, "MY_CHANNEL")
.SetSmallIcon(Resource.Mipmap.ic_notification_alert)
.SetContentTitle("Test1")
.SetContentText("This is a test")
.SetColor(GetColor(Resource.Color.colorPrimary));
NotificationManagerCompat.From(this).Notify(777, builder.Build());
我已经尝试将图标移动到 drawable 文件夹、mipmap 文件夹并使用
将图标缩小到恰好 48x48 像素突然使正确的颜色出现。 我仍然不明白这种未记录的行为。