How do I remove the divider from a listview on android? [duplicate]
Asked Answered
R

3

43

I'm developing a app that have a Listview, and the items from list already have a style I don't need the divider.

How do I set as hidden or remove the divider from the ListView?

Rademacher answered 15/4, 2012 at 15:6 Comment(1)
do the items need to be clickable?Reiterate
F
116

You can try android:divider="@null".

Formularize answered 15/4, 2012 at 15:10 Comment(1)
And in code it would be listView.setDivider(null);Pyromagnetic
K
14

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"
Kiblah answered 9/7, 2014 at 12:1 Comment(0)
S
4

Add

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

to your ListView

<ListView
  android:id="@+id/list_of_f"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_centerVertical="true"
  android:layout_margin="5dp"
  android:divider="@null"
  android:dividerHeight="0dp"
  android:listSelector="@android:color/transparent"/>
Squirt answered 21/4, 2014 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.