Adding “section dividers” to my layout?

The Android Design – Lists page describes “section dividers”. I’m aware you can use addHeaderView() a ListView for a similar effect. I would like to use a “section divider” without a ListView, but rather a LinearLayout.

In the screenshot below, I’m referring to the blue text “Phone” and “Email” which also has an line below it. The screenshot is from Android Design – Text Fields

  • Android Studio SDK location
  • Hidden Field in ListView Android?
  • Test events were not received - Android Studio
  • How to implement the deprecated methods of Notification
  • Using multiple text colors in Android's textview
  • Access resource defined in theme and attrs.xml android
  • enter image description here

    How do I go about adding it to my layout? It it simply a TextView plus a horizontal line?

  • Android Studio - SDK is out of date or is missing templates
  • Is there a multiplatform framework for developing iPhone / Android applications?
  • Android - Detect if Wifi Requires Browser Login
  • Howto avoid the “EACCES permission denied” ON SDCARD with KITKAT 4.4.2 Version. New policy from google
  • How to restore an Android app's default locale
  • Android drawing cache
  • 5 Solutions collect form web for “Adding “section dividers” to my layout?”

    I was looking for the same issue.
    I found an easy way to tell the app that a texview is a section separator:


    The line:


    add the underline to the text and style it accordingli to the defaulf “Separator” theme.

    Try to put this View after the TextView of “phone”. In this view I have put in a background color that you can change to your desire. Best of luck.

        android:background="#FF909090" />

    The solution ended up having an includable layout called util_horizontal_line_section.xml:

    <?xml version="1.0" encoding="utf-8"?>

    With the sectionSeparatorColour entry in values/colors.xml:

    <color name="sectionSeparatorColour">#a0a0a0</color>

    Includable via:

    <include layout="@layout/util_horizontal_line_section"/>

    On request of the asker of this question, I am writing my comment as an answer

    Create a background image with a line at the bottom, and set it as
    background to your TextView.

    TextView 2dp in height and width = match parent and set the background color as the color you want the line to be.

    You can do vertical as well by reversing the two settings.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.