Customization of the Item click effect of Android ListView
Preface:
Friends who develop listview Android know that they use a lot. There are many articles on the Internet about the Item click effects of Android ListView. I have read a lot of articles about listview myself. I will record good articles here. You can refer to them.
It was really unwise to do this effect before. I added a selector xml file to the Item layout file to achieve the Item click effect of ListView.
This is another way I can record how to use it in the future:
Create a new Item file as follows:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:Andro > <item android:state_pressed="true" android:drawable="@drawable/item_selector_pressed" /> <item android:state_focused="true" android:drawable="@drawable/item_selector_pressed" /> <item android:drawable="@android:color/transparent" /> </selector>
Introduce where ListView is neededandroid:listSelector="@drawable/item_selector"
In fact, this can only be blamed on me for writing selector files, which is easy to ignore. <item android:drawable="@android:color/transparent" />This point leads to a lot of detours to be completed, so remember it.
Thank you for reading, I hope it can help you. Thank you for your support for this site!