How to add Rounded Corner borders to Android Layout

If you want to add rounded corner to any kind of android view like linear layout, relative layout, button etc., follow the below method

Create a xml file under your drawable folder with following code. (The name of the file I created is rounded_corner.xml)


<?xml version="1.0" encoding="utf-8"?>
    <!-- view background color -->
        android:color="#a9c5ac" >
    <!-- view border color and width -->
        android:color="#1c1b20" >
    <!-- If you want to add some padding -->
        android:bottom="4dp"    >
    <!-- Here is the corner radius -->
        android:radius="10dp"   >

And keep this drawable as background for the view to which you want to keep rounded corner border. Let’s keep it for a LinearLayout

<LinearLayout android:layout_width="wrap_content"
        <TextView android:layout_width="fill_parent"
            android:text="Hi, This layout has rounded corner borders ..."