Metin Ilhan
Metin Ilhan

Reputation: 241

How to make inner radius for a rectangle shape?

the first image is result of following code. A rectangle with radius as expected but I need I rectangle which has inner radius on top right corner just like the second image.

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android" >
        <item >
            <shape android:shape="rectangle" >
                <corners  android:topRightRadius="50dp"
                    android:bottomRightRadius="0dp"
                    android:bottomLeftRadius="15dp"
                    android:topLeftRadius="15dp"  />
                <solid android:color="@color/turuncu"></solid>
            </shape>
        </item>
    </selector>

enter image description here enter image description here

Upvotes: 2

Views: 1858

Answers (1)

user1503122
user1503122

Reputation: 21

By using layer-list we can achive inner radius for the rectangle. Below code will give the second icon shape.

    <?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
        <item>
            <shape android:shape="rectangle">
                <solid android:color="@color/home_yellow"></solid>
                <corners android:radius="@dimen/margin20"></corners>
                <size android:width="100dp"
                    android:height="100dp" />
            </shape>
        </item>
        <item android:gravity="top|right">
            <shape android:shape="rectangle">
                <corners android:bottomLeftRadius="@dimen/margin45"
                    android:bottomRightRadius="@dimen/margin1"
                    ></corners>
                <solid android:color="#fff"></solid>
                <size android:width="35dp"
                    android:height="30dp" />
            </shape>
        </item>


    </layer-list>

Upvotes: 2

Related Questions