PreferenceFragmentCompat视图中会出现空格,这是由于icon未设置时引起的
values.xml中的iconSpaceReserved属性说明
<!-- Whether the space for the preference icon view will be reserved. If set to true, the
preference will be offset as if it would have the icon and thus aligned with other
preferences having icons. By default, preference icon view visibility will be set to
GONE when there is no icon provided, so the default value of this attribute is false.
-->
<attr format="boolean" name="iconSpaceReserved"/>
<attr name="android:iconSpaceReserved"/>
解决方法如下:
<EditTextPreference
app:iconSpaceReserved="false" // icon未设置时,此次应设置为false,否则会出现空格
app:key="real_name"
app:title=“title"
app:useSimpleSummaryProvider="true" />