1.
<?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 触摸时并且当前窗口处于交互状态 --> <item android:state_pressed="true" android:state_window_focused="true" android:drawable= "@drawable/pic1" /> <!-- 触摸时并且没有获得焦点状态 --> <item android:state_pressed="true" android:state_focused="false" android:drawable="@drawable/pic2" /> <!--选中时的图片背景--> <item android:state_selected="true" android:drawable="@drawable/pic3" /> <!--获得焦点时的图片背景--> <item android:state_focused="true" android:drawable="@drawable/pic4" /> <!-- 窗口没有处于交互时的背景图片 --> <item android:drawable="@drawable/pic5" /> </selector>
2.
<?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/red" /> <!-- 指定按钮松开时的图片 --> <item android:state_pressed="false" android:drawable="@drawable/purple" /> </selector>
时间: 2024-10-06 10:43:39