Android - drawable with rounded corners at the top only Android - drawable with rounded corners at the top only android android

Android - drawable with rounded corners at the top only


Try giving these values:

 <corners android:topLeftRadius="6dp" android:topRightRadius="6dp"         android:bottomLeftRadius="0.1dp" android:bottomRightRadius="0.1dp"/>

Note that I have changed 0dp to 0.1dp.

EDIT: See Aleks G comment below for a cleaner version


Try to do something like this:

<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android">    <item android:bottom="-20dp" android:left="-20dp">        <shape android:shape="rectangle">            <solid android:color="@color/white" />            <corners android:radius="20dp" />        </shape>    </item></layer-list>

It seems does not suitable to set different corner radius of rectangle. So you can use this hack.


In my case below code

    <?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android">    <item android:top="10dp" android:bottom="-10dp"        >        <shape android:shape="rectangle">            <solid android:color="@color/maincolor" />            <corners                android:topLeftRadius="10dp"                android:topRightRadius="10dp"                android:bottomLeftRadius="0dp"                android:bottomRightRadius="0dp"            />        </shape>    </item>    </layer-list>