<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="First Category"
android:textSize="20px">
<CheckBoxPreference
android:title="Checkbox Preference"
android:defaultValue="false"
android:summary="This preference can be true or false"
android:key="checkboxPref" />
</PreferenceCategory>
</PreferenceScreen>
我需要更改 PrefereceCategory
、CheckboxPreference
和 android:summary
的 android:title
字体大小。这些标签没有任何 android:textSize
属性。谁能帮我怎么弄到这个?
最佳答案
最后,我只需通过一个布局就可以解决我的问题。也许这会对某人有所帮助。 这是我修改后的preference.xml,见下面的代码。我们可以将自己的属性应用于首选项标题和摘要。
preference.xml:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="First Category"
android:textSize="20px"
android:layout="@layout/mylayout">
<CheckBoxPreference
android:title="Checkbox Preference"
android:defaultValue="false"
android:summary="This preference can be true or false"
android:key="checkboxPref"
android:layout="@layout/mylayout"/>
</PreferenceCategory>
</PreferenceScreen>
mylayout.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"/>
<TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="26sp"/>
</LinearLayout>
如有任何疑问,请询问我....保持微笑。如果这有用,请给我一条评论。
关于android - 如何更改 PreferenceScreen 中的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5334828/