How do I style my button in Android app?

Please Share On:

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.

  1. First create a button_selector.xml in drawable folder. Insert the following code.
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns: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"  />            
<item android:state_focused="true">
 <shape android:shape="rectangle"  >
     <corners android:radius="5dp" />
     <stroke android:width="1dip" android:color="#971E05" />
     <solid android:color="#58857e"/>       
<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" />            

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


That’s all you need to do to style you android app buttons.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright @2023. All Right Reserved.

Social media & sharing icons powered by UltimatelySocial