Can anyone tell me how to reduce the width and height of CheckBox in order to display very small CheckBox in Android ?
Thanks In Advance,
Can anyone tell me how to reduce the width and height of CheckBox in order to display very small CheckBox in Android ?
Thanks In Advance,
Simply use setWidth(w) and setHeight(h) functions as you would for a normal Button.
setWidth(int)
and setHeight(int)
since CheckBox
extends CompoundButton
which extends Button
Try referring to this tutorial
Alernatively try changing it via the XML:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new checkbox"
android:background="@drawable/my_checkbox_background"
android:button="@drawable/my_checkbox" />
UPDATE: this only works from API 17 onwards...
As per my answer on this question: - how can we reduce the size of checkbox please give me an idea
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