Search code examples
androidmaterial-designandroid-preferences

Preference grouping without title


In the Android Settings section of the Material Design Guidelines, it mentions that section titles are optional for preference groupings, and in the image, the last section shows a grouping without a title but with a divider between groupings.

However, I am not able to implement this properly. If I use a PreferenceCategory with no title set, there is a blank space where the title would be. I can't just throw in a View in a PreferenceScreen to a draw a divider, and the promising looking PreferenceGroup is abstract or otherwise not able to be used.

So, how can I achieve this?


Solution

  • You can get the divider using app:allowDividerAbove="true" or app:allowDividerBelow="true" as per your need. Using PreferenceCategory tag is not needed as these attributes can be set in any level of preference hierarchy.