Rounded Button in Android Studio

Create beautiful buttons in XML.

Rounded Button in Android Studio

Creating rounded corners on Button's is easy with Android Studio. Follow this tutorial as a guide. First, right click on the drawable folder on the left side of Android Studio, then select New then Drawable resource file.

File name can be rounded_corners. Then press Ok.

You should then be presented with your file titled rounded_corners.xml. This is what it will look like:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

</selector>

We need to edit this file. Replace this file with the following.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="24dp" />
    <solid android:color="#F00" />
</shape>

Open the Preview pane on the right side of the screen, and you should see a preview of the rounded corners with a red background.

To actually use this file, open content_main.xml (or whatever your layout file is) and add a background of the new rounded corners:


    <Button
        android:layout_width="200dp"
        android:layout_height="40dp"
        android:layout_margin="40dp"
        android:background="@drawable/rounded_corners"
        android:text="Rounded Buttons"
        android:textColor="#FFF"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

That's it!

Rounded Corners with a Border

More Tutorials

Kotlin Challenge #1

Build a simple contacts manager.

Android Basic Alert Dialog Box
Basic CardView

Basic CardView

Material Design.

Rounded Corners with a Border
Rounded Button in Android Studio

Rounded Button in Android Studio

Create beautiful buttons in XML.

RecyclerView Day 3: Invoicing app

RecyclerView Day 3: Invoicing app

Built with Android Studio and Kotlin.

Build a Ridesharing Android App - Part 1

Build a Ridesharing Android App - Part 1

Getting started is sometimes the hardest part.

setOnClickListener

Add a click listener in Kotlin.

Android Login Layout

Let users sign in.