简体   繁体   中英

Android resize checkbox

I created my own selector to the checkbox, but can't change the size of it. If I set layout_height from wrap_content to eg 20dp, the line height gets smaller but the size of the checkboxes stays resulting in overlapping each other. If I set android:height="20dp" and android:width="20dp" with the layout_height and width, nothing happens. Why?

<?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" />

Why don't you put

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

in your layout xml only. That works, but not the way you'd love to see it. Why don't you apply your images as checkboxes and resize them to whatever size you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM