Create Rounded corner button in android

Sky blue color rounded rectangular button.

Rounded corners buttons are basically used where app developer wants its app more simple + beautiful environment because simple buttons are not so much attractive but rounded buttons are awesome. Rounded buttons also looks like the real buttons designed in Photoshop. So here is the complete step by step tutorial for How to Create Rounded corner button in android.

android-project-download-code-button

How to Create Rounded corner button in android.

1. Create rounded_button_settings.xml file on Layout folder.

add new xml file in android project

Put below code into rounded_button_settings.xml file.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
 <shape android:shape="rectangle">
 <solid android:color="#55dcf9"/>
 <corners android:radius="10dp" />
 </shape>
 
</item>
</selector>

Code for MainActivity.java file.

 package com.android_examples.com.roundedbutton;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 }

 
}

Code for activity_main.xml layout file.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.android_examples.com.roundedbutton.MainActivity" >

 <Button
 android:id="@+id/button1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentTop="true"
 android:layout_centerHorizontal="true"
 android:layout_marginTop="186dp"
 android:text="Sample Button"
 android:textColor="#f8f9f9"
 android:background="@layout/rounded_button_settings" />

</RelativeLayout>

Screenshot :

Create Rounded corner button in android

Click Here To Download Create Rounded corner button in android project.

Leave a Reply

Your email address will not be published. Required fields are marked *