android - 如何更改 PreferenceScreen 中的字体大小

标签 android android-layout android-preferences

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

我需要更改 PrefereceCategoryCheckboxPreferenceandroid:summaryandroid: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/

相关文章:

android - .android 文件夹中没有 debug.keystore

java - 更改 EditTextPreference 的对话框消息颜色

Android PreferenceFragment 找不到 fragment ID 的 View

android - Fedora 14 上使用 Eclipse 时的 Android SDK 问题

java - 将 fragment Activity 上下文传递给自定义 ListView 适配器

java - 我的应用程序刚刚崩溃,如何获取崩溃日志?

android - DialogFragment 内的 Viewpager - 对话框高度错误

android微调器下拉列表

android - 控制 ListActivity 中的各个 View

java - 导致错误的android偏好设置