Custom checkboxes for Android

for my custom checkbox I used a simple ninepack that I created with android studio (from png which was 512x512px).

Here is the checkbox xml for custom:

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

    <item android:drawable="@drawable/ic_checkbox_unchecked" android:state_checked="false"/>
    <item android:drawable="@drawable/ic_checkbox_checked" android:state_checked="true"/>
    <item android:drawable="@drawable/ic_checkbox_unchecked"/>

</selector>

      

I have read many threads on this subject, but I have not found any dealing with the size of the chekbox as my new checkbox is larger than possible. Any attempt to adjust to a fixed size, for example 30x30dp result is distorted.

So what size should the image display images be, and if the size of the drawables doesn't matter how to set the size of the checkbox as the size of the standard andorid checkbox?

+3


source to share


1 answer


Try to fix it with the following code:



android:button="@null"
android:background="@drawable/your_custom_checkbox_state.xml"

      

+2


source







All Articles