android - 你如何在android studio中更改通知的背景颜色?setColor() 方法正在改变文本颜色
问题描述
这是我正在使用的代码。这里的 setColor() 方法改变的是文本颜色而不是背景颜色。在线发布的解决方案对我不起作用。
Notification notification=new NotificationCompat.Builder(this,CHANNEL_ID_2)
.setSmallIcon(R.drawable.meditationhd)
.setLargeIcon(b)
.setColor(getResources().getColor(R.color.red))
.setColorized(true)
.setContentTitle(name)
.setContentText(singer)
.setSubText("Beta version")
.setStyle(new androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle())
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setOnlyAlertOnce(true)
.build();
NotificationManager notificationManager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0,notification);
解决方案
推荐阅读
- git - 如何完成 git submodule update --init --recursive 离线?
- javascript - 为什么 router.query 在第一次渲染时在 NextJS 中返回一个空对象?
- python - 函数参数内的函数调用
- php - WooCommerce 不同语言的评论/评论
- javascript - 在 React 中将页面的背景颜色(可以随时更改)调整为按钮的背景颜色
- vertica - 需要vertica中的所需日期格式
- c++ - 如何在 gmock 模拟方法中处理参数
- itk - 如何获取ITK中节点的物理坐标 :: Mesh from a 3D volume of ct images
- python - 从数据框中提取列并使用正则表达式创建新列
- python - 我有一个字符串为“11-2020”,我想在 Python 中将其转换为“NOV-2020”