Adding “section dividers” to my layout?
The Android Design – Lists page describes “section dividers”. I’m aware you can use
ListView for a similar effect. I would like to use a “section divider” without a
ListView, but rather a
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
How do I go about adding it to my layout? It it simply a TextView plus a horizontal line?
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:
<TextView android:id="@+id/address_label" style="?android:attr/listSeparatorTextViewStyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Address"/>
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.
<View android:layout_width="match_parent" android:layout_height="2dip" android:background="#FF909090" />
The solution ended up having an includable layout called
<?xml version="1.0" encoding="utf-8"?> <View xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="1dip" android:background="@color/sectionSeparatorColour"/>
sectionSeparatorColour entry in
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.