1

I have a question about the radius value inside the corners tag, what is this radius means actually? is there a center or what? sample xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

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

<solid
    android:color="@android:color/transparent" />

<stroke
    android:color="#FFFFFF"
    android:width="2dp" />

<size
    android:width="165dp"
    android:height="40dp" />

Arran Cudbard-Bell
  • 5,912
  • 2
  • 26
  • 48
FrankieWong
  • 53
  • 1
  • 7

1 Answers1

2

A picture is worth a thousand words enter image description here

I will demo for you. Here is the original rectangle

enter image description here

In your xml file

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

    <solid android:color="#22B14C" />
</shape>

The result

enter image description here

4 corners will be rounded by default, if you want round at a specific corner, you can use 4 of these tags:

  • android:bottomLeftRadius
  • android:bottomRightRadius
  • android:topLeftRadius
  • android:topRightRadius

Another example using android:bottomLeftRadius

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:bottomLeftRadius="45dp"/>

    <solid android:color="#22B14C" />
</shape>

The result

enter image description here

Son Truong
  • 13,661
  • 5
  • 32
  • 58