deeps
deeps

Reputation: 33

Vertical divider in android listview not working

I have a listview where i need to show contact pictures and its details. Format :

The vertical separator is not showing up at al! Here is my layout file for listitem: [Using relative layout here as I have some more views to be added in the list relatively]

<ImageButton android:id="@+id/pic"
                                  android:layout_alignParentTop="true"
                                  android:layout_alignParentLeft="true"/>      

<ImageView android:id="@+id/vertical_separator"
           android:orientation="vertical"
           android:layout_width="wrap_content"
           android:layout_height="fill_parent"
           android:background="@android:drawable/divider_vertical_bright"
           android:layout_toRightOf="@id/badge"
           android:layout_alignWithParentIfMissing="true"/>                                

<TextView android:id="@+id/details"
          android:layout_toRightOf="@id/verticalseparator"
          android:layout_alignTop="@id/badge"
          android:layout_alignWithParentIfMissing="true"/>

Even though the height is "fill_parent" , the divider is shown as a small dot after the contact picture. I tried changing the width to 2dp ..but still the same.

--I use a ListAdapter to this type to fill in the list:

Am I missing anything here? The horizontal divider is shown correctly, but not the vertical divider

Upvotes: 2

Views: 2412

Answers (2)

Romain Guidoux
Romain Guidoux

Reputation: 2951

You can take advantage of Android's framework by using the android:divider and android:dividerPadding XML attributes:

<LinearLayout
    android:orientation="horizontal"
    android:baselineAligned="false"
    android:showDividers="middle"
    android:divider="?android:dividerVertical"
    android:dividerPadding="8dp"
    ...>

Source: https://docs.google.com/file/d/0Bz3qX4EBhUvwZWlHekI3Y0wxSUk/view?sle=true (slide 23)

Upvotes: 1

Martin Stone
Martin Stone

Reputation: 13007

I think "@id/badge" in the ImageView and TextView should be "@id/pic" instead. (Or the other way around.)

Upvotes: 1

Related Questions