简体   繁体   English

Android设置偏好类别的背景色

[英]Android set background color of preference category

I try to customize the background color of preference categories. 我尝试自定义首选项类别的背景颜色。 I already changed the background color of a preferences itself but I can't find a way how to change the the categories background color. 我已经更改了首选项本身的背景色,但是找不到找到如何更改类别背景色的方法。

I found two ways but they don't works for me: changing the preference category label color background 我发现了两种方法,但它们对我不起作用: 更改首选项类别标签的颜色背景

Through this link , i found this , but nothing I've tried worked for me. 通过此链接 ,我发现了这一点 ,但是我没有尝试过对我有用。 These layout snippet is what I've tried so far: 这些布局片段是到目前为止我尝试过的:

<resources>
    <style name="setBackgroundTheme" parent="android:Theme">
        <item name="android:background">@color/darkbluelogo</item>
    </style>
</resources>

In onCreate method I set the theme with: onCreate方法中,我将主题设置为:

setTheme(R.style.setBackgroundTheme);

Custom a layout file with your background color, set it in your PreferenceCategory: 使用背景颜色自定义布局文件,然后在您的PreferenceCategory中进行设置:

<PreferenceCategory
    android:layout="@layout/your_layout">

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

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