Custom Button Shape in Android

Android provide many of standard views such as Button, TextView and ImageView. We are also able to create custom view as per our requirenment.
One day I have seen skype login button, which is too pretty. So I think to make it for android. In this tutorial you may see how to customize Button in Android.


Using Shape drawable we can create custom shapes. Shape drawables provide this basic shapes: Rectangle, Oval, Line, and Ring. This all shapes have this below attributes

gradient  : For gradient backgrounds
solid        : For solid background color
padding  : For padding between the edge of the shape and its contents
size         : For the width and height
stroke     : For a stroke line around the edge of the shape

Let’s see simple example for button shape. Make this xml files in drawable folders

custom_button_border.xml for simple border in button

custom_button_round_rect_border.xml for rounded border of button

custom_button_round_rect2_border.xml for another custom shap

Now for button click effect we use selector


You can create all effect as per requirement, I have create just two effect for sample. button_focused.xml for when button is focused.

button_pressed.xml for when button pressed

Now run project. Our output looks like below,


Download Project.


Now see next tutorial Alert Dialog in Android.

(Visited 12,855 times, 10 visits today)