2

I'm having the following problem: I have a ListView and I get the layout for its items from an xml file. The thing is, though, that there should be some space between sequential items which I accomplish by nesting my layout into a dummy RelativeLayout just so that I can set marginTop =" " to the layout containing the item. The problem is that when the user clicks an item of the ListView the whole area (including the gap between sequential items) becomes selected. How do I deal with this? Thanks!

asenovm
  • 6,397
  • 2
  • 41
  • 52

3 Answers3

12

Instead of nesting items in a RelativeLayout, why not try using the listview's own "divider" to separate items?

In your ListView xml, add:

android:dividerHeight="15 dip"

(or some other value)

Cephron
  • 1,577
  • 1
  • 19
  • 26
3

try this:

ListView android:id="@+id/MyListView"
  android:layout_height="wrap_content"
  android:layout_width="wrap_content"
  android:divider="@android:color/transparent"
  android:dividerHeight="10.0sp"
Roman Marius
  • 456
  • 3
  • 9
  • 21
0

Create your own List View by extending BaseAdapter class in a separate class. you can refer to this

Community
  • 1
  • 1
Nilesh Tupe
  • 7,655
  • 5
  • 25
  • 30