Adding “section dividers” to my layout?

前端 未结 5 890
渐次进展
渐次进展 2020-12-24 15:33

The Android Design - Lists page describes \"section dividers\". I\'m aware you can use addHeaderView() a ListView for a similar effect. I would lik

相关标签:
5条回答
  • 2020-12-24 16:06

    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.

    0 讨论(0)
  • 2020-12-24 16:08

    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"/>
    

    The line:

    style="?android:attr/listSeparatorTextViewStyle"
    

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

    0 讨论(0)
  • 2020-12-24 16:09

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

    <?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"/>
    

    With the sectionSeparatorColour entry in values/colors.xml:

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

    Includable via:

    <include layout="@layout/util_horizontal_line_section"/>
    
    0 讨论(0)
  • 2020-12-24 16:19

    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" />
    
    0 讨论(0)
  • 2020-12-24 16:19

    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.

    0 讨论(0)
提交回复
热议问题