listview的属性listselector使用解析
一:概述
ListView的listSelector属性可以为列表的某个元素被点击时产生按下的效果。
二:问题:
某些情况下这个listSelector属性的效果会被覆盖,比如列表的Item为一个占满单元格的ImageView的时候,ImageView如果有内容那么listSelector的效果就会被挡住。该怎么办?
三:解决办法
解决的办法是为ListView添加drawSelectorOnTop属性并设置为true。
四:listView的drawSelectorOnTop属性
drawSelectorOnTop的解释:
When set to true, the selector will be drawn over the selecteditem. Otherwise the selector is drawn behind the selected item. The default value is false.
五:解释
当设置为true,selector 将绘制在被点击item的上面,反之绘制在被点击item的下面,默认为false。
eg:
android:drawSelectorOnTop="true"
android:drawSelectorOnTop="false"点击某条记录不放,颜色会在记录的后面,成为背景色,但是记录内容的文字是可见的