【发布时间】:2021-05-07 15:26:35
【问题描述】:
我正在我的应用中显示通知。我希望状态栏中的小图标为白色,但通知本身为另一种颜色(绿色),如this question 中所述。
我使用 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());
我已经尝试将图标移动到可绘制文件夹、mipmap 文件夹并使用the aforementioned question 中提到的工具。我正在安装 Android 8.0.0 的三星 Galaxy S7 上进行测试。我错过了什么?
【问题讨论】:
标签: c# android xamarin.android android-notifications