Layer List ignore <size> tag

896 views Asked by At

I want to create a custom Radio Button.

I using with <selector> and <layer-list> to show small circle on large circle, when the user select it.

But it seems to ignore the <size> tag completely!

My code is bellow:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="false">
    <shape>
        <size android:width="40dp" android:height="40dp"></size>
        <corners android:radius="5dp"></corners>
        <solid android:color="@color/blue"/>
    </shape>
</item>
<item android:state_checked="true">
    <layer-list>
        <item>
            <shape>
                <size android:width="40dp" android:height="40dp"/>
                <corners android:radius="5dp"/>
                <solid android:color="@color/blue"/>
            </shape>
        </item>
        <item>
            <shape>
                <size android:width="20dp" android:height="20dp"/>
                <corners android:radius="5dp"/>
                <solid android:color="@color/white"/>
            </shape>
        </item>
    </layer-list>
</item>

1

There are 1 answers

0
offset On BEST ANSWER

I've seen this problem a lot, and the only solution I found is:

<item android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp">
    <shape>
        <solid android:color="@color/blue"/>
    </shape>
</item>

If you have a better solution - answer!