Android View rounded corners

  • SumoMe

To create rounded corners in a view, first create a xml file

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle" >
            <corners android:radius="15dip" />
            <solid android:color="#404f64" />
            <stroke android:width="2dp" android:color="#bebfc1"/>
        </shape>
    </item>
</layer-list>

Save the file as rounded.xml or other name in the /res/layout folder.

For android:shape you can use one of this values:
Constant Value Description
rectangle 0 Rectangle shape, with optional rounder corners.
oval 1 Oval shape.
line 2 Line shape.
ring 3 Ring shape.

After that go to the layout which you want to make with rounded corners and add this:

android:background="@layout/rounded"

And the result must be:
Rounded corners

From now on you know how to decorate your forms and application. Good luck!

4 thoughts on “Android View rounded corners”

Leave a Reply


*