简体   繁体   English

如何在android中更改通知背景颜色?

[英]How to change notification background color in android?

how do I change notification color in android? 如何更改android中的通知颜色? I tried this code but it only changed the title and icon color. 我尝试了这段代码,但它只更改了标题和图标颜色。

NotificationCompat.Builder(mContext,NOTIFICATION_CHANNEL_ID).setColorized(true).setColor(Color.parseColor("#f7da64")

在此输入图像描述

  1. Make sure the Theme/Color used is consistent in 确保使用的主题/颜色一致

    • application tag of manifest file 清单文件的应用标签
    • all style files (style.xml,style.xml(v21)) 所有样式文件(style.xml,style.xml(v21))
  2. Make sure in notificationBuilder.setColor(mNotificationColor) , mNotificationColor is really pointing to the expected color code. 确保在notificationBuilder.setColor(mNotificationColor)中,mNotificationColor确实指向了预期的颜色代码。

  3. Check if you are setting meidastyle as shown below 检查您是否正在设置meidastyle,如下所示

    .setStyle(new MediaStyle() .setShowActionsInCompactView( new int[]{playPauseButtonPosition})in compact view .setMediaSession(mSessionToken)) 紧凑视图中的.setStyle(new MediaStyle()。setShowActionsInCompactView(new int [] {playPauseButtonPosition})。setMediaSession(mSessionToken))

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

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