Create Rounded corner border in android [shape & Radius]

Create Rounded corner border in android

In android studio normally views which are provided are in solid rectangle shape , there for some time to make it more attractive and appealing to our app used we have to customize the shape of these views .

One of the way we use to make our views look better is .. we will try to make corners of the buttons or text views  , in corner shape . There for  to do so here in this article we are going to tell how we can make rounded corners of the views .

To make  rounded corner in android studio we will have to make an extra xml design file which will contain all the shape and other parameter regarding the outline ,background color etc.

To create Round shape xml  steps are :-


  1. Right click on Drawable
  2. select drawable resource file
  3. Give name to your xlm file and click ok .

Now make your round shape design in this 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="#999999"></solid>
        <corners android:radius="35dp"></corners>
        <stroke  android:width="4dp"></stroke>
    </shape>
</item>
</selector>
...

Create Rounded corner border in android

Here in this example we have shown two edit text ,  one with simple default design and second one with custom corners  .

<?xml version="1.0" encoding="utf-8"?>
<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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="softwoodcoder.com.test.home">


    <EditText
        android:layout_width="260dp"
        android:layout_height="50dp"
        android:layout_marginTop="50dp"
        android:layout_marginLeft="50dp"
        android:textColor="#160d0d"
        android:background="#999999"
        android:hint="Edit text without round corner " />

    <EditText
        android:layout_width="260dp"
        android:layout_height="60dp"
        android:paddingLeft="15dp"
        android:layout_marginTop="150dp"
        android:layout_marginLeft="50dp"
        android:textColor="#160d0d"
        android:background="@drawable/roundcorner"          //  <---  shape implemented here...
        android:hint="Edit text with round corner " />
</RelativeLayout>

Rounded Corner in android


Create Rounded corner border in android

for more tips and tricks stay connected with  softwoodcoder .

This Post Has Been Viewed 214 Times

Ajay Kumar

Ajay kumar is young indian boy who enjoy coding and passionate to make , break & Develop New Codes .

Leave a Reply

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