如何在 PreferenceScreen 中更改字体大小 [英] How can I change font size in PreferenceScreen

查看:144
本文介绍了如何在 PreferenceScreen 中更改字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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 属性.任何人都可以帮助我如何获得这个吗?

I need to change android:title font size of PrefereceCategory, CheckboxPreference and android:summary size. These tags don't have any android:textSize attribute. Can any one help me how to get this?

推荐答案

最后,我能够通过传递一个布局来解决我的问题.也许这对某人有帮助.这是我修改后的preference.xml 见下面的代码.我们可以将自己的属性应用到首选项标题和摘要中.

Finally I was able to solve my problem simply by passing one layout. Maybe this will be helpful to someone. This is my modified preference.xml see below code. We can apply our own properties to pref title and summary.

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>

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

Please ask me if any queries....Keep Smiling. If this is useful give me one comment.

这篇关于如何在 PreferenceScreen 中更改字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆