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!
            Asked
            
        
        
            Active
            
        
            Viewed 9,867 times
        
    3 Answers
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
- 
                    1that along with setting a transparent image for the divider worked. Thanks! – asenovm Mar 15 '11 at 20:35
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
