Maximus
Maximus

Reputation: 1309

Drawable with a four-color border

Is it possible to achieve the following as a drawable (for a background) using a Layer-List ???

enter image description here

Thanks!

Upvotes: 2

Views: 329

Answers (1)

Jaiprakash Soni
Jaiprakash Soni

Reputation: 4112

Try this 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>

Upvotes: 6

Related Questions