开发者

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


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


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜