0

Why PreferenceScreen in AndroidX not similar to original PreferenceScreen? Even in documentation we can see in the image that the screen is shifted right.

I started new project in AndroiX and the items in PreferenceScreen shifted and I have no dividers.

How to give it the old look without overhead with customization?

enter image description here

https://developer.android.com/guide/topics/ui/settings.html

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Pavel Poley
  • 5,307
  • 4
  • 35
  • 66

1 Answers1

1

That's because the preference automatically give you a space for an icon. You can disable that by disabling the space using app:iconSpaceReserved="false". Something like this:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

  <PreferenceCategory
      android:title="your_title"
      app:iconSpaceReserved="false">

     ...

  </PreferenceCategory>

</PreferenceScreen>
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • I am not remember this before `AndroidX`, or maybe i am wrong? – Pavel Poley Jul 21 '19 at 11:24
  • That's probably the cause. I vaguely remember, but I think I'm also facing the same problem only after upgrading to `AndroidX` preference. Facing this after upgrading my old project from support library 27 to AndroidX. – ישו אוהב אותך Jul 21 '19 at 11:26
  • i have also strange behavior, with `androidx.preference:preference:1.0.0` `iconSpaceReserved` have no effect on `PreferenceCategory`(the title is shifted), and `androidx.preference:preference:1.1.0-rc01` have effect – Pavel Poley Jul 22 '19 at 08:05