How do I remove lines between ListViews on Android?

deepthi picture deepthi · Dec 16, 2009 · Viewed 191.4k times · Source

I'm using two ListViews like this:

<ListView
   android:id="@+id/ListView"
   android:text="@string/Website"
   android:layout_height="30px"
   android:layout_width="150px"
   android:scrollbars="none"
   android:transcriptMode="normal"/>
<ListView
   android:id="@+id/ListView1"
   android:text="@string/Website"
   android:layout_height="30px"
   android:layout_width="150px"
   android:scrollbars="none"
   android:transcriptMode="normal"/>

There is one blank line between the two ListViews. How do I remove it?

Answer

dasilvj picture dasilvj · Dec 16, 2009

To remove the separator between items in the same ListView, here is the solution:

getListView().setDivider(null);
getListView().setDividerHeight(0);

developer.android.com # ListView

Or, if you want to do it in XML:

android:divider="@null"
android:dividerHeight="0dp"