Android: 复选框选择器无法正常工作

Android: Check box selector not working properly

我正在开发一个应用程序,我在其中使用了复选框并应用了选择器。我的复选框代码如下:

<CheckBox
    android:id="@+id/checkBox"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="0.5"
    android:button="@drawable/custom_checkbox"
    android:clickable="false"
    android:focusable="false"
    android:gravity="center" />

custom_checkbox.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/checkbox_checked" android:state_checked="true"/>
    <item android:drawable="@drawable/checkbox_checked" android:state_pressed="true"/>
    <item android:drawable="@drawable/checkbox_unchecked"/>

</selector>

checkbox_checked

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item android:drawable="@drawable/green_tic"/>
    <item>
        <shape android:shape="rectangle" >
            <corners android:radius="@dimen/corner_radius_for_ask_option"/>
            <size
                android:height="20dp"
                android:width="20dp" />
        </shape>
    </item>

</layer-list>

checkbox_unchecked

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >
            <stroke
                android:width="2px"
                android:color="@color/color_light_grey" />

            <corners android:radius="@dimen/corner_radius_for_ask_option" />

            <size
                android:height="20dp"
                android:width="20dp" />
        </shape>
    </item>

</layer-list>

以上代码在 Note 3 和同类 phone 上运行良好。看起来像:

但在 samsung s2 上它看起来像:

尝试为您的形状添加透明实体:

<shape android:shape="rectangle" >
    <corners android:radius="@dimen/corner_radius_for_ask_option"/>
    <size
        android:height="20dp"
        android:width="20dp" />
    <solid android:color="@android:color/transparent"/>
</shape>

另一个可绘制对象也是如此 XML。