Android - divider between items in vertical layout

19,288

Solution 1

You can use a textview to create a divider line

Example:

<TextView          
      android:layout_width="fill_parent" 
      android:layout_height="1px" 
      android:background="#DADADA" />

Solution 2

You can insert View with background of any color you want and

layout_height = "1dp" (or more if necesary) and

layout_width="fill_parent".

Share:
19,288
user802609
Author by

user802609

Updated on June 04, 2022

Comments

  • user802609
    user802609 almost 2 years

    Possible Duplicate:
    Android Drawing Separator/Divider Line in Layout?

    I am making something similar to a list view, without actually making a list view...

    I have a bunch of text views in a vertical layout, and I am wondering if it is possible to get some sort of divider line in between them. The line dividers like they have in List Views..

    Any help?

  • Josh
    Josh over 12 years
    Doesn't need to be a TextView, a regular View will do fine and will render faster.
  • Sam
    Sam over 12 years
    Yep, I just wanted to give an example.
  • rndstr
    rndstr over 12 years
    You should be using dp instead of px
  • Jarad Duersch
    Jarad Duersch about 11 years
    no do not use dp in this instance because android will scale down the 1dp to .75 px on lower dpi screens and that will be 0px. px is correct