Search code examples
androidandroid-shape

How to make round corner in both sides of stroke in shape xml


I tried to create a shape like this one:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
  <corners android:radius="0.5dp"></corners>
  <stroke
    android:width="@dimen/strokeWidth"
    android:color="@color/mycolor"/>
  <solid android:color="@color/transparent"></solid>
</shape>

This is what I got:

Round corner part

Can I make the inner corner round as the outer border (now it's square)?


Solution

  • Some changes in your code and your output is ready :

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <corners android:radius="30dp"></corners> <!-- change this -->
        <stroke
            android:width="20dp"
            android:color="@color/black"/>
    </shape>
    

    Output:

    enter image description here