自定义复选框图像和控制复选框命中区域

时间:2013-09-25 13:39:25

标签: android

我必须在我的工作中自定义复选框图像,最后我在how-to-change-default-images-of-checkbox找到了解决方案,它通过使用'android:button'属性很好用,但给我留下了另一个问题,复选框'android:button'属性已应用,难以检查和取消选中。
以下是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>

使用此选择器的复选框:

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

注意:没有'android:button'属性,复选框很容易检查和取消选中,有没有一种优雅的方法来解决这个问题?非常感谢。

0 个答案:

没有答案