Android调整大小复选框

时间:2012-03-30 15:39:29

标签: android checkbox

我为复选框创建了自己的选择器,但无法更改它的大小。如果我将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" />

1 个答案:

答案 0 :(得分:0)

你为什么不把

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

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