How to Android button rounded corners | Radius, ripple, corners, design?

Do you want to make the corners of a button round in Android? In this tutorial, you will learn an easy way to achieve this in Android.

Android button rounded corners

To create an Android button rounded corners have to use a new XML file. This new XML file will be inside a drawable folder. To change the corners of all sides of the button need only one attribute in the drawable XML file.

To change one or two or three corners, you have to use the following attributes:-

Build an Android app with rounded buttons designs:

Here is step by step creating a rounded corner button with background color in android.

Step 1. Create a new project “Build Your First Android App in Kotlin

Step 2. Create a new XML file and add the below code.

Filename: rounded_button.xml

Location: res/drawable/rounded_button.xml

Step 3. Add following code in “activity_main.xml

Adding a Button in UI.

Step 7. Now Run the application, in an emulator or on your Android device

Output screenshot Android corner button example:

Download source code of button design from an Activity in Kotlin

Q: What is an android material button and how to set the corners (radius) of it?

Answer: Material Button is a customizable button component with updated visual styles

How to Use

Read more official document link:

Q: How to create a circle button in android?

Answer: Same as the above example, use XML drawable file:

Save the following contents as round_button.xml in drawable folder.

Android Material Effect: Although FloatingActionButton is a better option, If you want to do it using XML selector, create a folder drawable-v21 in res and save another round_button.xml there with following XML.

And set it as background of Button in xml like this:


  1. To show all state: -enabled, disabled, highlighted, etc, you have to use selector as described here.
  2. You’ve to keep both files in order to make the drawable backward-compatible. Otherwise, you’ll face weird exceptions in previous android version


Q: How to create Android button rounded corners programmatically?

Answer: Here code for how to create GradientDrawable shape programmatically.

And change the radius for all corners of the button.

or Change the radius for specific corners of the button.

And finally, use this drawable as a background as of button widget:

Note: A button design topic is UI design. in this tutorial, we used a Kotlin programming language in Main Activity and will work the same with java code.

Do comment if you have any doubts and suggestions on this tutorial.

Note: This example (Project) is developed in Android Studio 3.3.2. Tested on Android 9 ( Android-P), compile SDK version API 28: Android 9.0 (Pie)
Coding in Kotlin

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.