17

It seems that there is a horizontal line by default at the bottom of each item in android listview. My problem is: how to let the line not display

cwiggo
  • 2,541
  • 9
  • 44
  • 87
David
  • 2,691
  • 7
  • 38
  • 50

4 Answers4

32

You can do using this code..

lvlist.setDivider(null);
lvlist.setDividerHeight(0);
Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
Nikhil
  • 16,194
  • 20
  • 64
  • 81
  • Your solution works. Is it possible to make that by xml configuraion? – David Jun 27 '11 at 07:58
  • @David May be try android:dividerHeight="0px" . if you think this is helpful then please right answer and upvote it so help to other also. – Nikhil Jun 27 '11 at 08:02
  • 6
    @David android:divider="#00000000" android:dividerHeight="0px" – Nikhil Jun 27 '11 at 08:07
  • android:divider="#00ffffff" android:dividerHeight="0px" did the trick for me. Null is not allowed as a value for divider in the layout. – moyheen Jan 08 '16 at 13:57
28

in xml:

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

and in java you can use this:

myList.setDivider(null);
myList.setDividerHeight(0);
Mohsen Abdollahi
  • 901
  • 13
  • 14
2

Check here: How to change color of Android ListView separator line?

You can try setting the divider height to 0px.

Community
  • 1
  • 1
sparkymat
  • 9,938
  • 3
  • 30
  • 48
1

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"
Sotti
  • 14,089
  • 2
  • 50
  • 43