How to change color of Android ListView separator line?

UMAR-MOBITSOLUTIONS picture UMAR-MOBITSOLUTIONS · Mar 3, 2010 · Viewed 254.5k times · Source

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

Answer

JeremyFromEarth picture JeremyFromEarth · Mar 3, 2010

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>