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" />





Recent Posts:
Hello there!,

You are using AdBlocker!

I am an independent developer trying to help fellow developers and students to resolve issues faced on a day-to-day basis, we 'Code to Care' . There is a lot of expenses involved in hosting and managing a website that's the reason we have ads.

A humble request to you to disable adBlocker on Code2care.org and support us pay our bills.

Thanks,
Cod2ecare - Line's of code for change.

To see contents reload page after unblocking
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and Software Developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include Learnings, Video Tutorials, Code Snippets, How Tos, Blogs, Articles, etc.