Skip to content Skip to sidebar Skip to footer

Remove Listview Separator(in The Xml Layout File)

How can I remove the rows separator in a ListView(if possible within the XML layout file where it's described)?

Solution 1:

Set the dividerHeight to zero and divider to null like this in xml:

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

Or in java:

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

Solution 2:

Simply put:

android:divider="@null"

Solution 3:

put below property in listview tag (in xml file)

android:divider="@null"

Solution 4:

You can set divider color as transparent color and divider height in 'ListView' properties to remove the divider like below:

android:divider="#00000000"android:dividerHeight="0dp"

Solution 5:

There are different ways to achieve this, but I'm not sure which one is the best (I don't even know is there is a best way). I know at least 2 different ways to do this in a ListView:

1. Set divider to null:

1.1. Programmatically

yourListView.setDivider(null);

1.2. XML

android:divider="@null" (this goes inside your ListView element)

2. Set divider to transparent and set its height to 0 to avoid adding space between listview elements:

2.1. Programmatically:

yourListView.setDivider(new ColorDrawable(android.R.color.transparent));
yourListView.setDividerHeight(0);

2.2. XML

android:divider="@android:color/transparent"android:dividerHeight="0dp"

Post a Comment for "Remove Listview Separator(in The Xml Layout File)"