如何更改 PreferenceScreen 中的字体大小

2023-12-26

<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>

我需要改变android:title字体大小为PrefereceCategory, CheckboxPreference and android:summary尺寸。这些标签没有任何android:textSize属性。任何人都可以帮助我如何得到这个吗?


最后我只需通过一个布局就可以解决我的问题。也许这会对某人有帮助。 这是我修改后的preference.xml,请参阅下面的代码。我们可以将自己的属性应用于首选标题和摘要。

偏好.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>

如果有任何疑问请询问我......保持微笑。如果这有用,请给我一条评论。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何更改 PreferenceScreen 中的字体大小 的相关文章

随机推荐