【发布时间】:2018-02-03 02:39:52
【问题描述】:
我正在开发一个为用户创建通知的应用程序。我希望图标在状态栏中显示为白色,但在下拉通知菜单中显示时显示为蓝色。以下是 Google Store 应用执行相同操作的示例。
状态栏中的白色通知:
下拉菜单中的彩色通知:
我怎样才能复制这个?我必须设置哪些属性?
编辑: 这是我当前的代码 - 我将图像全部设为白色,背景透明,因此在状态栏中看起来不错,但在通知下拉中,图像仍然是相同的白色:
private NotificationCompat.Builder getNotificationBuilder() {
return new NotificationCompat.Builder(mainActivity)
.setDeleteIntent(deletedPendingIntent)
.setContentIntent(startChatPendingIntent)
.setAutoCancel(true)
.setSmallIcon(R.drawable.skylight_notification)
.setColor(ContextCompat.getColor(mainActivity, R.color.colorPrimary))
.setContentTitle(mainActivity.getString(R.string.notification_title))
.setContentText(mainActivity.getString(R.string.notification_prompt));
}
【问题讨论】:
-
我能够解决这个问题 - 请在下面查看我的答案。
-
对于那些使用 admin sdk 进行通知的人!
标签: java android colors push-notification android-notifications