Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 更改listpreference摘要文本的颜色和大小_Android_Listpreference - Fatal编程技术网

Android 更改listpreference摘要文本的颜色和大小

Android 更改listpreference摘要文本的颜色和大小,android,listpreference,Android,Listpreference,我的应用程序中有listpreference,我想自定义它,我可以将主题设置为prefs activity,如下所示: <activity android:name=".Prefs" android:label="@string/app_name" android:theme="@style/PreferencesTheme"> 首选项样式: <?xml version="1.0" encoding="utf-8" ?> &l

我的应用程序中有listpreference,我想自定义它,我可以将主题设置为prefs activity,如下所示:

 <activity 
     android:name=".Prefs" 
     android:label="@string/app_name" 
     android:theme="@style/PreferencesTheme">

首选项样式:

<?xml version="1.0" encoding="utf-8" ?> 
<resources xmlns:android="http://schemas.android.com/apk/res/android">
 <style name="PreferencesTheme" parent="android:Theme">
 <item name="android:background">#FFDAB9</item> 
 <item name="android:textColor">@color/red_color</item> 
 <item name="android:textSize">20sp</item> 
</style>
</resources>

#FFDAB9
@颜色/红色
20便士
上述样式会更改ListPreference背景和ListPreference标题文本大小和文本颜色,但它不会以任何方式更改ListPreference摘要文本颜色或大小

我尝试了此代码,但不起作用:

 <item name="android:textColorSecondary">@color/red_color</item>   
@color/red\u color
任何帮助都将不胜感激,谢谢

我建议您做的是将上述文件的内容复制并保存到您自己的项目中,编辑该文件以使其外观符合您的要求(记住不要更改任何ID),并显示自定义列表首选项布局

您可以在xml中应用自定义首选项布局,如下所示:

<ListPreference
    android:key="pref_key"
    android:title="@string/my_list_preference"
    android:layout="@layout/custom_list_preference" />

我将这一行放入styles.xml中,它可以工作:

    <item name="android:textColorSecondary">#00CC00</item>
#00CC00

回答可能太迟了,但试着去掉你的颜色线

<item name="android:textColor">@color/red_color</item>
@color/red\u color
加上这三种颜色,分别是原色、副色和三色

<item name="android:textColorPrimary">@color/red_color</item>
<item name="android:textColorSecondary">@color/red_color</item>
<item name="android:textColorTertiary">@color/red_color</item>
@color/red\u color
@颜色/红色
@颜色/红色
你可以选择你想要的颜色,老实说,我从来没有在任何首选页面中看到过第三种颜色,但是主颜色是主颜色和大文本,次颜色是主颜色下面显示的小文本


希望能有所帮助。

我复制链接并创建布局,然后将其放在上面,在您解释时引用它,但其非工作摘要文本根据偏好使用“android:textColorSecondary”或“android:textColorSecondary”。