Android MediaStyle NotificationCompat的背景颜色 [英] Android MediaStyle NotificationCompat background color

查看:975
本文介绍了Android MediaStyle NotificationCompat的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Lollipop 5.1.1(Cyanogen)上测试三星S4,我的应用程序使用支持库23.2.1

I'm testing on a Samsung S4 on Lollipop 5.1.1 (Cyanogen) and my app uses support library 23.2.1

我想知道如何更改MediaStyle NotificationCompat的背景颜色。

I would like to know how to change the background color of a MediaStyle NotificationCompat.

在构建器中,使用

.setColor(mNotificationColor)

不会更改背景。

令我困惑的是,Google提供的android-UniversalMusicPlayer-master示例(使用支持库23.2.1编译)成功地使用相同的方法来更改背景颜色。

What confuses me a little bit that the android-UniversalMusicPlayer-master example provided by Google (compiled with support library 23.2.1) uses successfully the same method to change the background color.

我知道文档说setColor的参数是int:使用的重音颜色(而不是背景颜色),但是再次android-UniversalMusicPlayer-master

I know that the doc says that the argument of setColor is "int: The accent color to use" (and not the background color) but again android-UniversalMusicPlayer-master does it successfully.

推荐答案

我找到了这个问题的原因。我使用v4 appcompat支持库而不是v7

I have found the reason for this problem. I used the v4 appcompat support library instead of the v7

所以替换:

import android.support.v4.app.NotificationCompat;

由:

import android.support.v7.app.NotificationCompat;

修复了此问题。

是我的另一个问题的原因媒体样式通知。

This also was the reason of another of my issues with the media style notification.

这篇关于Android MediaStyle NotificationCompat的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆