简体   繁体   中英

Android Drawable Shape with 3 layer border

在此处输入图片说明 在此处输入图片说明

Hi I am trying to add a border to a view which has yellow border but it also has a black border on both sides of primary border.

Any ideas

Try this drawable layout for border on top and bottom

<?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="2dp"
            android:color="#ffff00" />
        <solid android:color="#000000" />
    </shape>
</item>

<item
    android:bottom="2dp"
    android:top="2dp">
    <shape android:shape="rectangle">
        <stroke
            android:width="2dp"
            android:color="#000000" />
    </shape>
</item>

</layer-list>

Try this for left and right border

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

<layer-list 
xmlns:android="http://schemas.android.com/apk/res/android">

<item>
    <shape android:shape="rectangle">
        <solid android:color="#ffff00"/>
    </shape>
</item>

<item android:left="4dp">
    <shape android:shape="rectangle">
        <solid android:color="#000000"/>
    </shape>
</item>


<item android:right="4dp">
    <shape android:shape="rectangle">
        <solid android:color="#000000"/>
    </shape>
</item>

</layer-list>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM