Create an xml file in the drawable folder and select the root element as “selector”.
<?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/toast" > </item> <item android:state_focused="true" android:drawable="@drawable/smart" > </item> <item android:drawable="@drawable/looking" > </item> </selector>
In the layout xml file let the background of the button refer to the above xml:
<Button android:id="@+id/badd" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/custom" />
And now you have something that looks like: