我们怎样才能减少复选框的大小请给我一个想法

2023-12-12

我们如何减少复选框的大小?请给我一个主意。


你可以定义自己的状态列表drawable,为不同的状态定义不同的图像,如下:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--When checkbox is checked-->
<item android:state_checked="true" android:drawable="@drawable/img_checkbox_on" />
<!--When checkbox is not checked-->
<item android:state_checked="false" android:drawable="@drawable/img_checkbox_off" />
</selector>

并通过以下方式将此选择器应用于 xml 中的复选框:

<CheckBox android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:button="@drawable/my_custom_checkbox" />
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我们怎样才能减少复选框的大小请给我一个想法 的相关文章

随机推荐