0

How to give space or background or divider between list view for one row in android.I have implemented onitem click in list view.if user click background or space or divider the how to avoid click event for backgroud?.can anybody tell how to do? Thanks

user386430
  • 4,837
  • 13
  • 41
  • 45

1 Answers1

0

use Android ListView Divider

<ListView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/cashItemsList"
     android:cacheColorHint="#00000000"
     android:divider="@drawable/list_divider" android:dividerHeight="1dp"></ListView>

or

Android ListView Divider

Created res/drawable/divider.xml as follows:

<?xml version="1.0" encoding="UTF-8"?>
<shape
  xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient android:startColor="#ffcdcdcd" android:endColor="#ffcdcdcd" android:angle="270.0" />
</shape>

And in styles.xml for listview item, I added the following lines:

<item name="android:divider">@drawable/divider</item>
    <item name="android:dividerHeight">1dp</item>
Community
  • 1
  • 1
Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36