A rectangular selection will not be displayed as a checkbox

I defined a rectangle that can be made as follows:

<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>

I can display drawble as an imageView without any problems. However, it is assumed that it will be used for a single flag state. My switch for the checkbox button is defined as follows:

<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>

And finally, my checkbox:

<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"/>

Can anyone say why this is not working? Thank you very much.

+5
source share
1 answer

You must add the size of the node to the form:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >
    <size android:width="30dp" android:height="30dp" />
    <solid android:color="@color/blueBase"/>
    <stroke
        android:width="1dp"
        android:color="@color/blueDark" />
</shape>
+10
source

All Articles