Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layer List ignore <size> tag

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>

like image 693
offset Avatar asked Dec 26 '22 02:12

offset


1 Answers

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!

like image 59
offset Avatar answered Dec 29 '22 00:12

offset