androidpreferences

How to add divider lines in between preferences (settings menu)?


In my settingsImage of my settings menu I have multiple preferences that don't have lines in between them, creating an ugly look. How do I fix this?


Solution

  • I think you're trying to add the dividers in custom preference.xml.

    It should be ease If you're using both PreferenceActivity or Preference Fragment.

    Just go to the onCreate method and call this

    ListView list = getListView();
    list.setDivider(); // pass null for no dividers or a valid drawable for dividers.