我正在使用以下内容settings.xml
来膨胀我的SettingsFragment
扩展android.support.v7.preference.PreferenceFragmentCompat
:
<android.support.v7.preference.PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.preference.PreferenceCategory
android:title="@string/settings_category_title_general">
<android.support.v7.preference.CheckBoxPreference
android:defaultValue="@string/settings_default_value_lorem"
android:key="@string/settings_key_lorem"
android:summary="@string/settings_summary_lorem"
android:title="@string/settings_title_lorem" />
</android.support.v7.preference.PreferenceCategory>
</android.support.v7.preference.PreferenceScreen>
文本在以下定义的四行summary
后被截断:com.android.support:preference-v7:24.2.1
res/layout/preferences.xml
<TextView android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignStart="@android:id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="4" />
布局检查器summary
也显示 id:
为了覆盖设置,我定义了以下样式:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="preferenceTheme">@style/AppPreferenceTheme</item>
</style>
<style name="AppPreferenceTheme" parent="@style/PreferenceThemeOverlay">
<item name="preferenceStyle">@style/AppPreference</item>
</style>
<style name="AppPreference" parent="@style/Preference">
<item name="android:layout">@layout/settings_item</item>
</style>
preferences.xml
并创建了一个名为settings_item.xml
which overwrites的原始布局文件的副本android:maxLines="4"
。
但是,该样式未应用。我background
在视图中添加了一种颜色summary
来检查这一点。