【问题标题】:Change ImageButton depend on notification background color更改 ImageButton 取决于通知背景颜色
【发布时间】:2017-10-04 13:46:31
【问题描述】:

我收到了自定义 RemoteView 的通知。我can 更改文本颜色,取决于通知背景颜色。但是当背景也是黑色时,我的黑色按钮在 api

【问题讨论】:

  • 你如何设置背景颜色
  • @SwapnilNandapure 我是默认通知背景颜色。它在 android = 5.0 上为白色。此外,一些操作系统可以覆盖此颜色
  • 好吧,你的意思是你想改变弹出通知的背景颜色。

标签: android android-layout android-notifications android-view android-resources


【解决方案1】:

您可以尝试使用以下代码为您的远程查看通知设置背景颜色。

NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(this);
nBuilder.setSmallIcon(R.drawable.not_icon)
  .setContentTitle(getCurrentSong().getTitle())
  .setContentIntent(notOpenOnClick);
// This is what sets the background color on <N devices
// It is an accent color on N+ devices
nBuilder.setColor(getResources().getColor(R.color.colorPrimary));
// Add actions via nBuilder.addAction()
// Set the style, setShowActionsInCompactView(0) means the first
// action you've added will be shown the non-expanded view
nBuilder.setStyle(new NotificationCompat.MediaStyle()
  .setShowActionsInCompactView(0));

【讨论】:

  • 谢谢,但我不想改变背景,我想改变图标
  • 哦,看以前的棒棒糖你可以使用任何图像,但从棒棒糖及以上你想使用矢量图标,如透明背景和你的白色图标。喜欢:image.flaticon.com/sprites/new_packs/… 获取其中一个并使用它。
【解决方案2】:

经过研究,我为api>=21使用黑色图标,为api

【讨论】:

    猜你喜欢
    • 2016-10-27
    • 1970-01-01
    • 2012-07-22
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-03
    相关资源
    最近更新 更多