Styling android button

If you want to style android button with custom style with background, custom font different enable disable state button colors you can do that using providing custom style to your button below is the example:

inside res/value folder

1st. style for the button 

<style name=“CustomButtonStyle” parent="Widget.AppCompat.Button">

    <item name="android:background">@drawable/button_background.xml</item>

    <item name="android:textSize">16sp</item>

    <item name="android:textColor">@color/black</item>

    <item name="android:fontFamily">@font/font_name</item>

    <item name="fontFamily">@font/font_name</item>

    <item name="textAllCaps">false</item>


2nd. in background we are supplying selector so we can have different enable / disable state background and text colors


<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="">

    <item android:drawable="@color/blue” android:state_enabled="true"/>

    <item android:drawable="@drawable/button_with_border” android:state_enabled="false"/>


3rd. now you see in above step we are supplying drawable in place of color for disable state because in place of just different color we want border button where we have colored border around button and different background color for that we need to take advantage of shape property


<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android=""


    <solid android:color="@color/white" />



        android:color="@color/blue” />


In above xml solid color is background and stroke color is the border color around button.


Popular posts from this blog

Using TabLayout and ViewPager with CollapsingToolbarLayout

Styling TextInput Layout with material design library

styling android TabLayout material design