【问题标题】:Android PreferenceFragmentCompat blank spaceAndroid PreferenceFragmentCompat 空格
【发布时间】:2018-08-28 16:52:32
【问题描述】:
【问题讨论】:
标签:
android
fragment
android-support-library
preferences
【解决方案1】:
我的解决办法是这样的:
custom_preference_category_material.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="start"
android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:textAlignment="viewStart"
android:textColor="?colorAccent" />
<TextView
android:id="@android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</FrameLayout>
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="preferenceTheme">@style/CustomPreferenceTheme</item>
</style>
<style name="CustomPreferenceTheme" parent="@style/PreferenceThemeOverlay">
<item name="preferenceCategoryStyle">@style/CustomPreferenceCategory</item>
<item name="preferenceStyle">@style/CustomPreference</item>
<item name="checkBoxPreferenceStyle">@style/CustomCheckBoxPreference</item>
<item name="dialogPreferenceStyle">@style/CustomDialogPreference</item>
<item name="switchPreferenceCompatStyle">@style/CustomSwitchPreferenceCompat</item> <!-- for pre lollipop(v21) -->
<item name="switchPreferenceStyle">@style/CustomSwitchPreference</item>
<item name="seekBarPreferenceStyle">@style/CustomSeekBarPreference</item>
<item name="preferenceScreenStyle">@style/CustomPreferenceScreen</item>
</style>
<style name="CustomPreferenceCategory" parent="Preference.Category.Material">
<item name="android:layout">@layout/custom_preference_category_material</item>
<item name="iconSpaceReserved">false</item>
</style>
<style name="CustomPreference" parent="Preference.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="CustomCheckBoxPreference" parent="Preference.CheckBoxPreference.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="CustomDialogPreference" parent="Preference.DialogPreference.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="CustomSwitchPreferenceCompat" parent="Preference.SwitchPreferenceCompat.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="CustomSwitchPreference" parent="Preference.SwitchPreference.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="CustomSeekBarPreference" parent="Preference.SeekBarPreference.Material">
<item name="iconSpaceReserved">false</item>
</style>
<style name="CustomPreferenceScreen" parent="Preference.PreferenceScreen.Material">
<item name="iconSpaceReserved">false</item>
</style>