10

I have got a trouble with layout of Preference screen after updated SDK to version 28 (Android Pie). Each PreferenceScreen has a new padding on the left.

As I've checked, there is a method to set icon space as reserved in Preference class already.

android.support.v7.preference.Preference.setIconSpaceReserved(boolean iconSpaceReserved)

The method is good so far, but the problem is that it doesn't work with PreferenceCategory.

Does this mean that the left padding on PreferenceCategory is not a space for icon?

Doctiger
  • 2,318
  • 2
  • 15
  • 28
  • I solved by a workaround with styles. It works with PreferenceCategory. https://stackoverflow.com/a/52573593/5256040 – T-igra Sep 30 '18 at 00:20

2 Answers2

8

Solved using app:iconSpaceReserved="false" in the preference xml (under each item).

    <PreferenceCategory
    android:title="Pro Settings"
    app:iconSpaceReserved="false"
    >

    <CheckBoxPreference
        android:defaultValue="false"
        android:key="plugin"
        android:title="@string/EnablePlugin"
        android:summary="@string/PluginDescription"
        android:id="@+id/Pref"
        app:iconSpaceReserved="false"
        />

</PreferenceCategory>
Fabio Fracassi
  • 289
  • 3
  • 7
3

it is a bug and already solved. you need to wait for the update

https://issuetracker.google.com/issues/111662669

  • A fix has now been released in androidx.preference 1.1.0-alpha01. I guess this means it will never be released in the com.android.support track. – mhsmith Nov 07 '18 at 19:29