1

I have created a preference screen and inflated in a class extending PreferenceFragmentCompat. But the dividers in between the preference items are not showing

Nataraj KR
  • 1,001
  • 10
  • 22

2 Answers2

6

If using AndroidX, add the following attributes to each of your preferences in XML:

<Preference
    ...
    app:allowDividerAbove="true"
    app:allowDividerBelow="true"
    ... />

You can also see a more detailed answer here: here

Maksim Ivanov
  • 3,991
  • 31
  • 25
-1

Wrap every 'Preference' with 'PreferenceCategory' tag to get divider between the preferences in your XML file

example:

<PreferenceCategory>
  <ListPreference ... />
</PreferenceCategory>
Nataraj KR
  • 1,001
  • 10
  • 22
  • That’s the easiest way to do it, but leaves you with the TOP GAP of the category title space. Looking for another solution – nnyerges Feb 07 '19 at 13:57
  • You can use Android-Support-Preference-V7-Fix at https://github.com/Gericop/Android-Support-Preference-V7-Fix . Take a look at the README markdown in the bottom of the page. – nnyerges Feb 07 '19 at 16:05