Android调整大小复选框



我为复选框创建了自己的选择器,但无法更改其大小。如果我将layout_height从wrap_content设置为例如20dp,则行高会变小,但复选框的大小会保持不变,从而导致彼此重叠。如果我用layout_height和width设置android:height="20dp"和android:width="20dp",什么都不会发生。为什么?

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/cbon" />
<item android:state_checked="false" android:drawable="@drawable/cboff" />
</selector>

        <CheckBox
            android:id="@+id/multiple_checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_gravity="center_vertical"
            android:checked="true"
            android:button="@drawable/productlists_custom_cb"
            android:clickable="false"
            android:focusable="false"
            android:focusableInTouchMode="false" />

为什么不放

android:layout_width="20dip"
android:layout_height="20dip"

仅在布局xml中。这是有效的,但不是你希望看到的方式。为什么不将图像应用为复选框,并将其调整为您想要的大小呢。

最新更新