0

我正在使用来自:https ://stackoverflow.com/a/10608622/1261256 的时间选择器类

在偏好屏幕上,除了与上述时间选择器类相关的“时间”之外,我还有几个选项(例如铃声)。

但是,“时间”的文本大于其他首选项的文本。我怎样才能使它统一?

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

上面的 xml 文件使用以下方法添加:

addPreferencesFromResource(R.xml.settings);
4

1 回答 1

0

我也遇到了这个。

该类TimePreference在其 2 参数构造函数中0为第三个参数调用 3 参数构造函数,该参数使用默认样式。由于这是一个 Preference 类,它应该将其android.R.attr.preferenceStyle作为第三个参数调用以使用首选项样式。对代码进行更改,使两个参数的构造函数如下所示:

    public TimePreference(Context ctxt, AttributeSet attrs) {
            this(ctxt, attrs, android.R.attr.preferenceStyle);
    }
于 2013-02-19T09:47:59.970 回答