我已经定义了一个矩形的drawable,如下所示:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="4dip"/>
<solid android:color="#FF000000" />
<stroke android:width="1dip" android:color="@color/service_checkbox_disabled_unchecked_stroke" />
</shape>
我可以将Drawable显示为ImageView,没有问题。然而,它应该是一个复选框的一种状态的Drawable。我的复选框按钮选择器定义如下:
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:drawable="@drawable/bg_services_tick_unchecked_disabled" />
<item android:state_checked="false" android:drawable="@drawable/bg_services_tick_unchecked_disabled" />
</selector>
最后是我的复选框:
<CheckBox
android:id="@+id/cb_tariff_3_next_month_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/checkbox_services"
android:layout_centerHorizontal="true"/>
有人能告诉我,为什么这行代码不起作用吗?非常感谢。