selector切换View不同状态

当View获取不同状态时显示图片:
1.imageselector.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="@drawable/arrow_pressed" />
	<item android:drawable="@drawable/arrow_normal" />
	<item android:state_checked="true" android:drawable="@drawable/arrow_pressed" />
</selector> 

2.main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:orientation="vertical" android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<!--  android:layout_height="wrap_content"-->
	<ImageView android:layout_width="wrap_content"
		android:layout_height="@android:dimen/app_icon_size"
		android:layout_alignParentRight="true" android:scaleType="fitCenter"
		android:layout_gravity="center" android:src="@drawable/imageselector"
		android:clickable="true" android:focusable="true" android:id="@+id/blacklistImageView"
		android:layout_marginRight="10dip" />
</LinearLayout>

你可能感兴趣的:(java,android,xml)