Create rounded corners RelativeLayout in android

Design custom RelativeLayout with smooth curve corners and background color change.

Rounded corners relative layout is used sometimes inside gaming android applications or Mobile gallery apps. So it can be easily created through layout file, all we have to do is create another layout file and set that layout to Relative Layout background. So here is the complete step by step tutorial for Create rounded corners RelativeLayout in android.

android-project-download-code-button

How to Create rounded corners RelativeLayout in android.

Code for MainActivity.java file.

package com.createroundedcornersrelativelayout_android_examples.com;
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.createroundedcornersrelativelayout_android_examples.com.MainActivity"
 android:background="@layout/relativelayout_custom_create" >

</RelativeLayout>

Code for relativelayout_custom_create.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="#01fee9"/>
 
 <stroke
 android:color="#019f92"
 android:width="3dp"/>
 <corners android:radius="30dp"/>
 
 </shape>
 </item>
</selector>

Screenshot :

Create rounded corners RelativeLayout in android

Click here to download Create rounded corners RelativeLayout in android project.

Leave a Reply

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