0

I am building an application with multiple list items in the home screen. Home screen configuration is as follows:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:weightSum="1">
<ImageView android:id="@+id/home_header" android:src="@drawable/home_header"
    android:layout_width="fill_parent" android:layout_height="wrap_content"></ImageView>

<LinearLayout android:layout_width="match_parent"
    android:layout_height="wrap_content" android:orientation="vertical"
    android:layout_gravity="top" android:id="@+id/HomeOptions">
    <!-- android:textFilterEnabled="true" -->
    <ListView android:id="@+id/HomeOptionsList"
        android:layout_width="fill_parent" android:layout_height="wrap_content">
    </ListView>
</LinearLayout>

Configuration of list item is as follows:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent" android:weightSum="1">

<TableRow android:id="@+id/listItem" android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ImageView android:id="@+id/icon" src="@drawable/icon"
        android:layout_width="wrap_content" android:layout_height="match_parent" />
    <TextView android:id="@+id/chat_type" android:textStyle="normal"
        android:paddingTop="12dp" android:paddingLeft="5dp"
        android:layout_width="wrap_content" android:layout_height="match_parent" android:textSize="20px"/>
    <ImageView android:id="@+id/home_msg_notification_icon" src="@drawable/message_recieved" android:paddingLeft="50dp"
        android:layout_width="match_parent" android:layout_height="match_parent"
        android:layout_gravity="right" />
    <!-- <ImageView android:id="@+id/error_notification_icon" src="@drawable/warning_icon" android:paddingLeft="50dp"
        android:layout_width="match_parent" android:layout_height="match_parent"
        android:layout_gravity="right" /> -->
</TableRow>

The output screen has a strange problem it does not shows divider lines for few items. When i try to drag the list item, the divider lines appear and then go away. I have attached a screen shot for you to look at.

Click here

user1009805
  • 1
  • 1
  • 1
  • This [question in google groups](http://groups.google.com/group/android-developers/browse_thread/thread/e1015b9559621e40) might be interesting (especially last post). – Knickedi Oct 23 '11 at 19:12

2 Answers2

0

mListView.setDividerHeight(1);

if you use 0.5dip on older devices it does not display

Barrie Galitzky
  • 1,166
  • 12
  • 14
0

In low resolutions devices (320x240 like the HTC wildfire), the list divider is not always displayed. The same divider can appear and disappear during scrolling.

I comes from the size approximation of the height of the divider.

In the ListView the default divider height is the size of the divider drawable, 1px height as I can see in Android source code, on a low resolution device it's displayed, for an unknown reason as 1px or 0px. The divider disappear when the size is rounded to 0px.

To make sure it's displayed correctly on all devices, I usually define the dividerHeight in px such as:

android:dividerHeight="1px"
ol_v_er
  • 27,094
  • 6
  • 48
  • 61