Husein Behboudi Rad
Husein Behboudi Rad

Reputation: 5462

Drawing a rectangle shape with colored rounded border

How we can draw a rectangle shape like below image for setting as linear layout back ground?

enter image description here

is it possible to have this with xml shape or I must use a png image?!

Upvotes: 0

Views: 521

Answers (1)

Biraj Zalavadia
Biraj Zalavadia

Reputation: 28484

Your shape is ready

<?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="14dp"
                />
            <solid
                android:color="#FFFFFF"
                />
            <padding
                android:left="0dp"
                android:top="0dp"
                android:right="0dp"
                android:bottom="0dp"
                />
            <size
                android:width="10dp"
                android:height="10dp"
                />
            <stroke
                android:width="2dp"
                android:color="#42929d"
                />


        </shape>
    </item>

    <item android:left="5dp" android:right="5dp" android:top="5dp" android:bottom="5dp">
        <shape android:shape="rectangle" >
            <corners
                android:radius="14dp"
                />
            <solid
                android:color="#FFFFFF"
                />
            <padding
                android:left="0dp"
                android:top="0dp"
                android:right="0dp"
                android:bottom="0dp"
                />
            <size
                android:width="10dp"
                android:height="10dp"
                />
            <stroke
                android:width="2dp"
                android:color="#42929d"
                />

        </shape>
    </item>

</layer-list>

OutPut:

enter image description here

Upvotes: 1

Related Questions