Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change color of Android ListView separator line?

I want to change color of ListView separator line. Any help would be appreciated.

like image 406
UMAR-MOBITSOLUTIONS Avatar asked Mar 03 '10 15:03

UMAR-MOBITSOLUTIONS


2 Answers

You can set this value in a layout xml file using android:divider="#FF0000". If you are changing the colour/drawable, you have to set/reset the height of the divider too.

<LinearLayout   xmlns:android="http://schemas.android.com/apk/res/android"   android:layout_width="wrap_content"   android:layout_height="wrap_content">    <ListView      android:id="@+id/android:list"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:divider="#FFCC00"     android:dividerHeight="4px"/>  </LinearLayout> 
like image 193
JeremyFromEarth Avatar answered Oct 10 '22 02:10

JeremyFromEarth


Or you can code it:

int[] colors = {0, 0xFFFF0000, 0}; // red for the example myList.setDivider(new GradientDrawable(Orientation.RIGHT_LEFT, colors)); myList.setDividerHeight(1); 

Hope it helps

like image 42
Asher Aslan Avatar answered Oct 10 '22 04:10

Asher Aslan