Question

I am unable to understand layer-list behaviour and the padding given inside the shape tag. I want to draw a check box like this

Required Image

After trying a lot, what I've achieved so far is

enter image description here

Code for above drawable is :

<item>
    <shape android:shape="rectangle" >
        <solid android:color="#ed145b" />
        <padding
            android:bottom="-5dp"
            android:left="-5dp"
            android:right="-5dp"
            android:top="-5dp" />
    </shape>
</item>

<item>
    <shape android:shape="rectangle" >
        <stroke
            android:width="4px"
            android:color="#ed145b" />

        <size
            android:height="20dp"
            android:width="20dp" />
    </shape>
</item>

Checbox is cutting from left side. And couldn't get any solution for it so far.

Was it helpful?

Solution

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" >
    <shape android:shape="rectangle" >
        <solid android:color="#ed145b" />
    </shape>
</item>

<item>
    <shape android:shape="rectangle" >
        <stroke
            android:width="4px"
            android:color="#ed145b" />

        <size
            android:height="20dp"
            android:width="20dp" />
    </shape>
</item>

Solved my problem by adding padding to the item not to the shape.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top