Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a rectangle with inverted rounded corners?

I know how to make rectangle with rounded corners, like this

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid
        android:color="#FF0000"/>
    <corners
        android:radius="10000dp" />
</shape>

It looks like this:

enter image description here

But I want to make the inverse of that (center transparent and sides filled with color), which should look like this:

enter image description here

Thanks

like image 754
Matej Procházka Avatar asked Dec 06 '18 08:12

Matej Procházka


1 Answers

Not proper way, but will get the result, try

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <padding
                android:bottom="-100dp"
                android:left="-100dp"
                android:right="-100dp"
                android:top="-100dp" />
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle">
            <corners android:radius="200dp" />
            <stroke
                android:width="100dp"
                android:color="#FF0000" />
        </shape>
    </item>
</layer-list>
like image 88
Athira Avatar answered Sep 20 '22 15:09

Athira