有没有一种简单的方法(属性?)来模仿ListView
项目在任何其他视图上的触摸反馈,例如LinearLayout
?
问问题
68 次
1 回答
0
android:listSelector="@drawable/list_sel"
在您的可绘制文件夹中,放入 list_sel:
list_sel.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="@drawable/list_bg" />
<item android:state_pressed="true"
android:drawable="@drawable/list_bg_sel" />
<item android:state_focused="true"
android:drawable="@drawable/list_bg_sel" />
</selector>
list_bg
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#77000000"
android:centerColor="#88000000"
android:endColor="#99000000"
android:angle="270"/>
</shape>
就我而言,list_bg_sel
是一个图像,但您也可以使用形状创建。
于 2013-03-27T08:43:46.930 回答