In this tutorial you will learn how to create a round button in android.
Shape drawable resource is used to define shape of a view. Below I have shared an example to to make a circle button.
Android Round Button Example
Create a xml file inside res/drawable folder.
round_button.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <stroke android:color="#FF6F00" android:width="3dip"/> <solid android:color="#FFC107"/> <size android:width="100dp" android:height="100dp"/> </shape>
shape: Defines shape of view. It can be rectangle, oval, line and ring. In this case we are using oval shape to make the button circular.
stroke: Defines boundary of shape.
solid: Defines background color of shape.
size: Defines size of shape.
Now set this xml as background of the button.
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" android:background="@drawable/round_button"/>
The button will look like:
You can customize its color and size according to your need.
Not working!