Android : Remove ListView Separator/divider programmatically or using xml property

The default behavior of Android ListView has a divider line that acts as a separator between two rows as shown in the below image,

If you wish to remove this line, it's possible both programmatically as well as using layout XML attributes, let's see both ways,

Remove ListView separator using XML property:

To remove the separator using XML property you must simply add android:divider="@null" property to the ListView View that you have defined in the layout file.

File: ListView Snippet
<ListView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/listViewWithoutSeperator"
     android:divider="@null"
     android:layout_below="@+id/fb_login_button"
     android:layout_toRightOf="@+id/fb_login_button"
     android:layout_toEndOf="@+id/fb_login_button"
     android:layout_marginTop="150dp" />

This is not an AI-generated article but is demonstrated by a human.

Please support independent contributors like Code2care by donating a coffee.

Buy me a coffee!

Buy Code2care a Coffee!

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!