首先是声明配置文件button_background.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/btn_pressed"/>
<item android:state_focused="true"
android:state_enabled="false"
android:drawable="@drawable/btn_disabled_focused"/>
<item android:state_focused="true"
android:drawable="@drawable/btn_focused"/>
<item android:state_enabled="false"
android:drawable="@drawable/btn_disabled"/>
<item android:drawable="@drawable/btn_normal"/>
</selector>
然后在layout文件中直接Button
android:background="@drawable/button_background"