Android rounded corners in a layout with different radius values

I am trying to make an intention with a transparent background and a solid background with some basic information and rounded corners. I can currently use a rounded shape if all the corners have the same radius using

<corners android:radius="20dp" />

But if I try to have, say, only a lower rounding 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="#cccccc" />
<corners android:radius="20dp" android:topLeftRadius="0dp"
    android:topRightRadius="0dp" 
    android:bottomLeftRadius="20dp"
    android:bottomRightRadius="20dp" />
</shape>

or something like that, then I get an error in my layout that says

layout.xml: java.lang.UnsupportedOperationException

any suggestions?

+5
source share
1 answer

Try giving up android:radius=20dpand just have separate radii. In addition, you should probably switch to dipinstead dp.

0
source

All Articles