The buttons are important widget in Android and by default it has a rectangular shape. In this tutorial we learn about how to create round corner button, oval button and capsule shape of button. First of all create a xml file in a drawable folder and call it as a background into code of button widget. I have named it as round_corner, oval and capsule shape respectively.
round_corner.xml
1 2 3 4 5 6 7 8 |
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="#000"/> <corners android:radius="10dp"/> </shape> |
Now call it as a background of button in Button code.
Button Code
1 2 3 4 5 6 |
<Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/round_corner" android:textColor="#FFFF" /> |
Demo:

round corner button
Similarly we can do it for oval shape of button.
oval.xml
1 2 3 4 5 6 7 8 |
?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:dither="true" android:shape="oval"> <solid android:color="#000"/> </shape> |
Similarly we can also create capsule or cylindrical like button in Android.
capsule.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:bottomLeftRadius="35dp" android:bottomRightRadius="35dp" android:radius="60dp" android:topLeftRadius="35dp" android:topRightRadius="35dp" /> <solid android:color="#000" /> <padding android:bottom="0dp" android:left="0dp" android:right="0dp" android:top="0dp" /> <size android:height="60dp" android:width="270dp" /> </shape> |
- Round corner button circular button oval button android
- Round corner button circular button oval button android
Source: Offical documentation of Android