selector属性:
android:state_pressed是否点击
android:state_focused焦点获取
android:state_selected是否选择
android:state_enabled 是否可用
android:state_window_focused 当前界面是否可用
android:state_pressed是否点击
android:state_focused焦点获取
android:state_selected是否选择
android:state_checkablecheckbox是否可用
android:state_checkedcheckbox是否选中android:state_enabled 是否可用
android:state_window_focused 当前界面是否可用
属性值也可以叠加使用 android:state_window_focused="true" android:state_pressed="true"
该xml放在drawable文件中
<?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/l1"></item> <item android:drawable="@drawable/l2" android:state_pressed="false"></item> </selector>