textColor属性不起作用.这是我的XML:
<PreferenceCategory
android:title="Title"
android:textColor="#00FF00">
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有PreferenceScreen和一些PreferenceCheckBoxes.我想更改textColor和textSize的标题和摘要以及CheckBox的图像选中和取消选中.所以我android:layout用来改变这个属性.
我的ChceckBoxPreference:
<CheckBoxPreference
android:layout="@layout/preference_checkbox"
android:key="temp"
android:title="@string/title"
android:summary="@string/summary"
android:defaultValue="true"
/>
Run Code Online (Sandbox Code Playgroud)
当我使用android:widgetLayout它看起来很奇怪.这是我的preference_checkbox.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="10dp"
>
<TextView
android:id="@+android:id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray"
android:textSize="20sp"
/>
<TextView
android:id="@+android:id/summary"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/gray"
android:textSize="14sp"
/>
</LinearLayout>
<CheckBox
android:id="@+android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
带有id @+android:id/title和摘要的标题@+android:id/summary显示正确的值.但是,尽管默认值和id的复选框@+android:id/checkbox无法正常工作.它没有显示正确的值,我无法更改首选项中保留的值.不使用任何布局,我可以通过触摸整个CheckBoxPreference来更改复选框的值.但现在(使用我的布局)我只能通过触摸此复选框来更改复选框的值.如何以正确的方式为所有功能制作CheckBoxPreference的布局?
我的PreferenceScreen有很长的标题,特别是在某些语言中.我可以使用以下方法为CheckBoxPreference或ListPreference设置多行标题: Android首选项摘要.如何总结3行?,但如何为PreferenceScreen设置2行标题?我可以改变这里的样式:如何在PreferenceScreen中更改字体大小但这看起来并不完美,并且它与首选项样式(字体,大小......)不一致.
谢谢!