首页 > 解决方案 > 在drawable中制作一个布局,它有3个相同颜色的边框,一个是不同的

问题描述

实际上,我为我的布局背景制作了一个可绘制的资源文件。我希望我的布局应该有 3 个相同颜色的面和一个不同颜色的面。

在这段代码中,布局的所有面都是红色的。我想要 3 应该有红色和 1 应该有白色。

<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <corners
        android:bottomLeftRadius="5dp"
        android:bottomRightRadius="5dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp" />

    <stroke  android:color="@color/colorLightRed" android:width="1dp">

    </stroke>
</shape>

标签: android

解决方案


你可以试试这样的。我猜它不是最好的解决方案..

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="-2dp">
    <shape>
        <corners
                android:bottomLeftRadius="5dp"
                android:bottomRightRadius="5dp"
                android:topLeftRadius="5dp"
                android:topRightRadius="5dp" />
        <stroke
                android:width="1dp"
                android:color="@color/black30">
        </stroke>
    </shape>
</item>
<item
        android:bottom="-2dp"
        android:left="-2dp"
        android:top="-2dp">
    <shape>
        <corners
                android:bottomLeftRadius="5dp"
                android:bottomRightRadius="5dp"
                android:topLeftRadius="5dp"
                android:topRightRadius="5dp" />
        <stroke
                android:width="1dp"
                android:color="@color/green">

        </stroke>
    </shape>
</item>


推荐阅读