ImageView设置点击效果需要注意两点,第一个设置android:clickable="true",第二个 <item android:drawable="@drawable/button_n"/>属性必须放到最后才能生效
<?xml version="1.0" encoding="utf-8"?><!--发现大类列表项--> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ivCategory" android:layout_width="@dimen/x110" android:layout_height="@dimen/x110" android:src="@drawable/bt_icon_pxb" android:clickable="true" android:background="@drawable/bt_discover_category"> </ImageView>
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/button_d" android:state_checked="true"/> <item android:drawable="@drawable/button_d" android:state_pressed="true"/> <item android:drawable="@drawable/button_n"/> </selector>