这是我的代码,一切正常。
val builder = NotificationCompat.Builder(this, "NOTI_ID")
.setSmallIcon(R.drawable.ic_stat_name)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setColor(ContextCompat.getColor(this, R.color.colorPrimaryDark))
Run Code Online (Sandbox Code Playgroud)
唯一的问题是我无法更改标题的颜色(=“Hello World”)。最后一行.setColor(ContextCompat.getColor(this, R.color.colorPrimaryDark))仅更改图标颜色。我在文档中找不到任何内容,如果您查看这些图像,您会看到标题与图标的颜色相同。所以我不确定错误是来自我还是我的代码缺少某些内容?
编辑
标题是指应用程序名称。抱歉,这是我的错误。不是内容标题,而是应用程序的名称。例如检查那些图像。