Layer List ignore <size> tag

落花浮王杯 提交于 2019-12-23 16:43:23

问题


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:


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!



来源:https://stackoverflow.com/questions/26841517/layer-list-ignore-size-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!