Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why divider is not showing in the listview @android:id/list ?

I have a linear layout that contain the following listview :

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:cacheColorHint="#00000000"
    android:divider="#FF0000"
    android:dividerHeight="4dp"
     />

and the layout is used by a ListActivity, the issue is that the following line in ListView xml doesn't take effect :

     android:divider="#FF0000"
    android:dividerHeight="4dp"

and the default divider is set. Do you why this happening and how to fix it?

like image 946
Jimmy Avatar asked Mar 16 '12 16:03

Jimmy


1 Answers

its an difference of the dp and px.

use this

android:dividerHeight="4px"

instead of

android:dividerHeight="4dp"

and use this also if you want

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

you will get it..

like image 122
Arpit Patel Avatar answered Oct 05 '22 06:10

Arpit Patel