如何在形状的笔画两侧制作圆角 xml

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

我尝试创建这样的形状:

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

这是我得到的:

我可以把内角做成外边框(现在是正方形)吗?

试试这个, 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"

试试这个

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

输出:-

对您的代码进行一些更改,您的输出已准备就绪:

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

输出: