可绘制四色边框

时间:2014-01-03 04:03:23

标签: android android-layout android-ui android-drawable

是否可以使用Layer-List ???

实现以下作为drawable(用于背景)

enter image description here

谢谢!

1 个答案:

答案 0 :(得分:6)

试试这个xml:

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

    <item
        android:bottom="10dp"
        android:right="10dp">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <solid android:color="#0000FF" />
        </shape>
    </item>
    <item
        android:right="10dp"
        android:top="10dp">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <solid android:color="#FF0000" />
        </shape>
    </item>
    <item
        android:left="10dp"
        android:top="10dp">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <solid android:color="#FFFF00" />
        </shape>
    </item>
    <item
        android:bottom="10dp"
        android:left="10dp">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <solid android:color="#00FF00" />
        </shape>
    </item>
    <item
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <solid android:color="#0000FF" />
        </shape>
    </item>
    <item
        android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp">
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle" >
            <solid android:color="#3f3f3f" />
        </shape>
    </item>

</layer-list>