0

I have to customize checkbox image in my work, finally i found the solution at how-to-change-default-images-of-checkbox , it works well by using 'android:button' attribute, but left me another problem, checkbox with 'android:button' attribute applied, become hard to check and uncheck.
Following is the selector for Checkbox:

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/gn_checkbox_checked" android:state_checked="true"/>
    <item android:drawable="@drawable/gn_checkbox_normal" android:state_checked="false"/>
    <item android:drawable="@drawable/gn_checkbox_normal"/>

</selector>

And the checkbox using this selector:

<CheckBox
    android:id="@+id/timeline_check"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:button="@drawable/checkbox"
    android:layout_marginRight="3dp" />

Notes: Without 'android:button' attribute, checkbox is easy to check and uncheck, is there an elegant way to solve this problem? Thanks a lot.

Community
  • 1
  • 1
gaols
  • 341
  • 5
  • 13
  • What is the difference between hard to `check/uncheck` and `easy to check/uncheck`? I suppose the touch area is small of your image. If so, use a larger image (at least use some padding in the image). – Sherif elKhatib Sep 25 '13 at 13:45
  • The image size for checkbox is 11dp * 11dp, my phone screen resolution is xxdpi(1080*1280), is 11dp too small to touch? actually most of the times i cannot touch it. – gaols Sep 25 '13 at 14:19
  • 1
    The xhdpi image should be 39x39 pixels, which means the dp value should be 20x20 or 19x19. I have taken these values by inspecting `android.R.drawable.checkbox_off_background` – Sherif elKhatib Sep 25 '13 at 14:24
  • Use a bigger image become much better now, thank you for your advice. – gaols Sep 28 '13 at 03:18

0 Answers0