?????ImageView??????????????????????????¡ê?????????????§¹???????§»?????????????????????????????????????????????res/drawable??????¡ä??????xml?????????my.xml,???????¡ê?
-
<?xml version="1.0" encoding="utf-8"?>
-
<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
<item android:state_pressed="true"
-
android:drawable="@*android:drawable/btn_search_dialog_voice_pressed" />
-
<item android:state_pressed="false"
-
android:drawable="@*android:drawable/btn_search_dialog_voice_default" />
-
</selector>
???????
????????????????????????drawable????????????????????????????????????????????????
-
android:drawable="@drawable/ic_desk_point_normal"
???????
????????imageView??xml????????????
-
android:src="@drawable/youPicture"
-
android:background="@drawable/my"
???????
??????????§¹????
???????XML?????.xml?????????list_item_bg.xml????????????????ListView???§Ò???????????????????????
drawable/list_item_bg.xml
-
<?xml version="1.0" encoding="utf-8" ?>
-
<selector xmlns:android="http://schemas.android.com/apk/res/android">
-
<!-- ??????????? -->
-
<item android:drawable="@drawable/pic1" />
-
-
<!-- ??§ß??????????? -->
-
<item android:state_window_focused="false"
-
android:drawable="@drawable/pic1" />
-
-
<!-- ??????????y??????????????? -->
-
<item android:state_focused="true" android:state_pressed="true"
-
android:drawable= "@drawable/pic2" />
-
-
<!-- ???????¦Ì??????????? -->
-
<item android:state_focused="false" android:state_pressed="true"
-
android:drawable="@drawable/pic3" />
-
-
<!--???????????? -->
-
<item android:state_selected="true"
-
android:drawable="@drawable/pic4" />
-
-
<!--??y???????????? -->
-
<item android:state_focused="true"
-
android:drawable="@drawable/pic5" />
-
</selector>
???????
??¡Â???
-
?????????listview??????android:listSelector=”@drawable/list_item_bg”
-
?????????listview??item?????????android:background=”@drawable/list_item_bg”
-
????????java??????????Drawable drawable = getResources().getDrawable(R.drawable.list_item_bg);listview.setSelector(drawable);
????§Ò??????????????????????????????????????
android:cacheColorHint="@android:color/transparent"
|