1

我想从内部去除桃色纯色,只希望它位于顶部、左侧和右侧的边界。底部颜色红色很好。我到处搜索,但他们只建议使用纯色来覆盖整个红色边框。

XML 代码

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <!-- Draw a 2dp width border around shape -->
            <stroke
                android:color="#ff1e0c"
                android:width="2dp"
                />
        </shape>
    </item>
    <!-- Overlap the left, top and right border using background color  -->
    <item
        android:bottom="2dp"
        >
        <shape android:shape="rectangle">
            <solid android:color="#fffbce"/>
        </shape>
    </item>

</layer-list>

现在的样子

4

1 回答 1

1

试试这个解决方案,

<?xml version="1.0" encoding="utf-8"?>

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- This is the line -->
    <item android:bottom="1dp">
        <shape>
            <solid android:color="#00000000" />
            <stroke
                android:width="1dp"
                android:color="#FF0000" />
        </shape>
    </item>
    <item
        android:bottom="-1dp"
        android:left="0dp"
        android:top="0dp">
        <shape>
            <solid android:color="#00000000" />
            <stroke
                android:width="1dp"
                android:color="#000000" />
        </shape>
    </item>


</layer-list>
于 2015-12-31T11:31:05.620 回答