Updated answer
After further testing it appears that the dividers will only show if the height of the divider is strictly less than the dividerHeight
set for the ListView. For instance:
custom_divider.xml
(Note that the divider height is specified by android:width
)
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:width="1dp"
android:color="$ffff0000" />
</shape>
Layout xml
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:divider="@drawable/custom_divider"
android:dividerHeight="2dp"/>
...Will work. But this will not:
custom_divider.xml
(Note that the divider height is specified by android:width
)
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:width="1dp"
android:color="$ffff0000" />
</shape>
Layout xml
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:divider="@drawable/custom_divider"
android:dividerHeight="1dp"/>
My guess is that Google messed up with the optimization for drawing Listview dividers and will simply not draw them if there is not enough room.
Original post
Looks like you need to both set the dividerHeight
on the ListView and the stroke width
of the divider drawable for this to work on Android 5.
Example:
custom_divider.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:width="10dp"
android:color="$ffff0000" />
<gradient android:height="1dp" />
</shape>
Layout xml
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:divider="@drawable/custom_divider"
android:dividerHeight="20dp"/>