【问题标题】:Shape with an alternated bi-color border in android studioandroid studio中具有交替双色边框的形状
【发布时间】:2021-01-06 07:47:07
【问题描述】:

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

Shape with cool alternated border

【问题讨论】:

    标签: android-studio colors border shapes


    【解决方案1】:

    好的,我做了一些工作,并找到了一个与我不完全一样的解决方案,但我想它已经足够好了。这是放入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

    希望这对任何人都有帮助

    【讨论】:

      猜你喜欢
      • 2012-10-24
      • 2014-03-13
      • 1970-01-01
      • 2014-01-19
      • 2015-03-10
      • 2015-06-12
      • 2021-08-08
      • 1970-01-01
      相关资源
      最近更新 更多