how can we reduce the size of checkbox please give me an idea

前端 未结 7 939
时光说笑
时光说笑 2021-01-16 00:11

How can we reduce the size of checkbox? Please give me an idea.

相关标签:
7条回答
  • 2021-01-16 00:29

    You can reduce the size of the checkbox by changing its layout_width & layout_height.

    0 讨论(0)
  • 2021-01-16 00:30

    Everything is standard, put in layout xml:

        <CheckBox android:id="@+id/myCheckBoxId"
                  android:checked="false"
                  android:text="Check It!" 
                  android:textSize="12"/> <!--look here --/>
    
    0 讨论(0)
  • 2021-01-16 00:35

    Use android:scaleX="0.5" android:scaleY="0.5"

    1 is for 100% size 0.5 is for 50% 0.4 is for 40%...

    0 讨论(0)
  • 2021-01-16 00:41

    UPDATE: this only works from API 17 onwards...


    CheckBox derives its height from the TEXT as well as the image.

    Set these properties in your XML:

    android:text=""
    android:textSize="0sp"
    

    Of course this only works if you want no text (worked for me).

    Without these changes, the CheckBox was giving me a big margin around my image, as mentioned by Joe Plante.

    0 讨论(0)
  • 2021-01-16 00:44

    You can just use scaleX and scaleY properies:

    <CheckBox
     android:id="@+id/check_box"            
     android:scaleX="2.5"
     android:scaleY="2.5"/>
    
    0 讨论(0)
  • 2021-01-16 00:51

    You can define your owm state list drawable, to define different images for different states, as below:

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

    and apply this selector to check box in xml by:

    <CheckBox android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:button="@drawable/my_custom_checkbox" />
    
    0 讨论(0)
提交回复
热议问题