I am using the following settings.xml
to inflate my SettingsFragment
extending 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>
The summary
text is cut off after four lines which is defined in com.android.support:preference-v7:24.2.1
in 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" />
The layout inspector shows the summary
id as well:
To overwrite the setting I defined the following styles:
<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>
and created a copy of the original layout file preferences.xml
named settings_item.xml
which overwrites android:maxLines="4"
.
However, the style is not applied. I added a background
color to the summary
view to check this.
From the JavaDoc of the
Preference
constructor:So change your styles to: