2

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)?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Kingfisher Phuoc
  • 8,052
  • 9
  • 46
  • 86

3 Answers3

1

Try this

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <stroke
                android:width="30dp"
                android:color="#000000" />
            <corners android:radius="40dp" />
        </shape>
    </item>
</layer-list>

output :-

enter image description here

Manohar
  • 22,116
  • 9
  • 108
  • 144
1

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

halfer
  • 19,824
  • 17
  • 99
  • 186
Ali
  • 3,346
  • 4
  • 21
  • 56
0

try this, abc.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="-10dp"
        android:left="-10dp"
        android:right="-10dp"
        android:top="-10dp">
        <shape android:shape="rectangle">
            <stroke
                android:width="10dp"
                android:color="#ffffff" />
            <corners android:radius="20dp" />
        </shape>
    </item>
</layer-list>

layout.xml

android:background="@drawable/abc"
Gautam Surani
  • 1,136
  • 10
  • 21