reiley
reiley

Reputation: 3761

Creating drawable with layer-list

I've to create below image using layer-list.

Note: Assuming the cloudy icon in the middle is available. So bassically: 1. How to draw a box with red background. 2. 1dp black border. 3. Place an available image in the middle of the rectengle enter image description here

Upvotes: 0

Views: 1429

Answers (1)

cooperok
cooperok

Reputation: 4257

Layout xml:

<View android:layout_width="200dp"
    android:layout_height="100dp"
    android:background="@drawable/my_drawable" />

Drawable xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">
        <stroke android:width="1dp" android:color="#000000"/>
        <solid android:color="#FF0000"/>
    </shape>
</item>
<item>
    <bitmap android:gravity="center" android:src="@drawable/icon"/>
</item>
</layer-list>

Upvotes: 1

Related Questions