Search code examples
androidandroid-preferencesandroidx

Preference in androidX looks diffrent


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


Solution

  • 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>