Add this file into drawable folder in res folder
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" > <shape> <gradient android:startColor="#FFFFFF" android:endColor="#FFEEEE" android:angle="270" /> <stroke android:width="2dp" android:color="#454545" /> <corners android:radius="3dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> <item android:state_focused="true" > <shape> <gradient android:endColor="#FF0000" android:startColor="#AA0000" android:angle="270" /> <stroke android:width="2dp" android:color="#FFFFFF" /> <corners android:radius="3dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> <item> <shape> <gradient android:endColor="#FF0000" android:startColor="#AA0000" android:angle="270" /> <stroke android:width="2dp" android:color="#454545" /> <corners android:radius="3dp" /> <padding android:left="10dp" android:top="10dp" android:right="10dp" android:bottom="10dp" /> </shape> </item> </selector>
And set background to button like
<Button android:text="Click Me !" android:id="@+id/button1" android:background="@drawable/red_button" android:layout_margin="10dp" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>
That's it !!
1 comment:
Nice!
Post a Comment