I am sharing my project work tutorial with all of you so that it will help you to style your button. This is the procedures I applied while styling my android app buttons.
- First create a button_selector.xml in drawable folder. Insert the following code.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<stroke android:width="1dip" android:color="@color/green_temp" />
<gradient android:angle="-90" android:startColor="@color/green_temp" android:endColor="@color/green_temp" />
</shape>
</item>
<item android:state_focused="true">
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<stroke android:width="1dip" android:color="#971E05" />
<solid android:color="#58857e"/>
</shape>
</item>
<item >
<shape android:shape="rectangle" >
<corners android:radius="5dp" />
<stroke android:width="1dip" android:color="@color/bright_green" />
<gradient android:angle="-90" android:startColor="@color/green_temp" android:endColor="@color/button_green" />
</shape>
</item>
</selector>
2. Add these following colors in colors.xml of values folder.
<!-- Green -->
<color name="green_temp">#23A96E</color>
<color name="green_dark">#159204</color>
<color name="bright_green">#02D8B0</color>
<color name="button_green">#10a54a</color>
3. Finally in your button of xml put background from our selector
<Button
android:id="@+id/btnAddTitle"
android:layout_below="@id/edEnterTitleValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/btn_AddTitle"
android:background="@drawable/button_selector"
android:layout_margin="20dp"
/>
That’s all you need to do to style you android app buttons.