How to highlight ListView-Items

后端 未结 4 1719
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 15:30

i got the following problem.

i have a ListView with custom rows consisting of an imageview and a textview. the textview\'s xml code is



        
4条回答
  •  生来不讨喜
    2021-02-07 16:02

    This is how it should look using selector:

    Create a file within drawable called selector_listview_item.xml, which looks like (change the colors to your own):

    
    
        
        
        
        
    
    

    Now in your layout which describes the list row (e.g. layout_list_row.xml), On the root layout add the android:background="@drawable/selector_listview_item", So the layout would look something like:

    
    
        android:orientation="vertical">
    
        
    
    

    (Note: you might want to add android:focusable="false" on you items within that listview row, to make the row clickable, as mentioned here)

    Done.

提交回复
热议问题