You just need to set selector
of button
in your layout file.
<Button
android:id="@+id/button1"
android:background="@drawable/selector_xml_name"
android:layout_width="200dp"
android:layout_height="126dp"
android:text="Hello" />
and done.
Edit
Following is button_effect.xml
file in drawable
directory
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/numpad_button_bg_selected" android:state_selected="true"></item>
<item android:drawable="@drawable/numpad_button_bg_pressed" android:state_pressed="true"></item>
<item android:drawable="@drawable/numpad_button_bg_normal"></item>
</selector>
In this, you can see that there are 3 drawables, you just need to place this button_effect
style to your button
, as i wrote above. You just need to replace selector_xml_name
with button_effect
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…