简体   繁体   English

Android首选项文字大小

[英]Android preferences text size

I'm using time picker class from: https://stackoverflow.com/a/10608622/1261256 我正在使用以下时间选择器类: https : //stackoverflow.com/a/10608622/1261256

On preference screen, I have several options (eg ringtone) in addition to 'Time', which is tied to the above time picker class. 在首选项屏幕上,除了上述上面的时间选择器类中的“时间”外,我还有几个选项(例如铃声)。

However, the text for 'Time' is larger than the text for the other preferences. 但是,“时间”的文本大于其他首选项的文本。 How can I make it uniform? 如何使它均匀?

This is settings.xml: 这是settings.xml:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

<CheckBoxPreference
    android:defaultValue="true"
    android:key="notification" />

<com.xxxx.TimePreference
    android:key="notification_time"
    android:dependency="notification"
    android:title="@string/pref_notification_time" />

<RingtonePreference
    android:defaultValue="content://settings/system/notification_sound"
    android:dependency="notification"
    android:key="notification_ringtone"
    android:ringtoneType="notification"
    android:title="@string/pref_title_ringtone" />

</PreferenceScreen>

Above xml file gets added using: 上面的xml文件使用以下方法添加:

addPreferencesFromResource(R.xml.settings);

I just ran into this too. 我也碰到了这个。

The TimePreference class, in its 2 parameter constructor, calls the 3 parameter constructor with 0 for the third parameter, which uses the default style. TimePreference类在其2参数构造函数中,调用3参数构造函数,对于第三个参数,其0使用默认样式。 Since this is a Preference class, it should call it with android.R.attr.preferenceStyle as the third parameter to use the preference style. 由于这是一个Preference类,因此应使用android.R.attr.preferenceStyle作为第三个参数来调用它,以使用首选项样式。 Make a change to the code so the two parameter constructor looks like this: 更改代码,以便两个参数构造函数如下所示:

    public TimePreference(Context ctxt, AttributeSet attrs) {
            this(ctxt, attrs, android.R.attr.preferenceStyle);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM