mercredi 17 février 2016

Android checkbox set check image size

I am trying to set the size of a checkbox check and finally found something that works in the preview but does not work on the emulators / my device. Does anyone know of a way to set the dimensions of an image in a layer-list? I have tried making the drawable the background as well but it had the same issues.

Here is my drawable

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://ift.tt/nIICcg">
    <item android:state_checked="true">
        <layer-list>
            <item>
                <shape android:shape="rectangle">
                    <solid
                        android:width="2dp"
                        android:color="@color/greyBlue" />
                    <size
                        android:width="30dp"
                        android:height="30dp" />
                </shape>
            </item>
            <item android:drawable="@drawable/image_diamond" android:width="20dp" android:height="20dp" android:gravity="center"/>
        </layer-list>
    </item>
    <item android:state_checked="false">
        <shape android:shape="rectangle">
            <solid
                android:width="2dp"
                android:color="@color/greyBlue"/>
            <size
                android:width="30dp"
                android:height="30dp" />
        </shape>
    </item>
</selector>

Here is the preview

android studio preview

Here is the emulator

android studio emulated device

How can I size the image that is the check? I can't use insets or padding because those make the check bounds larger.




Aucun commentaire:

Enregistrer un commentaire