android studio 中带有交替双色边框的形状

Shape with an alternated bi-color border in android studio

我想创建一个形状用作元素的背景,因为该应用程序以红色和橙色为主色我想制作一个很酷的边框,但是我只设法找到如何放置单一的颜色,并不知道如何进行某种设计。 我想做这样的事情(我在绘画中很快做了这个只是为了展示我的想法):

Shape with cool alternated border

好吧,我做了一些工作并得出了一个解决方案,虽然这不是我想要做的,但我想它已经足够好了。这是放入 drawable 文件夹中 xml 文件的代码:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape
            android:shape="rectangle"
            android:padding="10dp">
            <solid android:color="#FFFFFF"/>
            <corners
                android:bottomRightRadius="20dp"
                android:bottomLeftRadius="20dp"
                android:topLeftRadius="20dp"
                android:topRightRadius="20dp"/>

            <stroke
                android:width="10dp"
                android:color="@color/colorAccent"/>
        </shape>
    </item>
    <item>
        <shape
            android:shape="rectangle"
            android:padding="10dp">
            <corners
                android:bottomRightRadius="20dp"
                android:bottomLeftRadius="20dp"
                android:topLeftRadius="20dp"
                android:topRightRadius="20dp"/>

            <stroke
                android:width="8dp"
                android:color="@color/colorPrimary"
                android:dashGap="10dp"
                android:dashWidth="8dp" />
        </shape>
    </item>
</layer-list>

此代码将产生此结果:

shape with bicolor border

希望这对大家有帮助