我已通知自定义远程视图。我可以更改文本颜色,取决于通知背景颜色。但是当背景黑色时,我的黑色按钮仍然在API< 21上看不见。有什么方法可以在不改变背景的情况下解决此问题?
您可以尝试使用以下代码将背景颜色设置为远程视图通知。
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));
研究后,我将黑色图标用于api> = 21,而白色图标则为api&lt;21。