In Android, click listview to change the color of item and set listselector to be invalid

This is the same problem. Clicking item in listview will change the color, because listview sets the default listselector, which has a default color. Similarly, if there is no color change, how we set listselector will not change the color.

However, in our development process, we may encounter such problems. Listview click the same color and summarizes the following reasons:

1. Set the background color value in the layout of item, and remove the background color

2. The effect of listselector attribute in listview is overwritten. For example, when the item of the list is an ImageView that occupies a full cell, if the ImageView has content, the effect of listselector will be blocked

At this time, we need to add the drawselectorontop property in the listview and set it to true

The above is the solution that Xiaobian introduced to you. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>