In a Xamarin Android application, I have an AppCompatRadioButton with the drawableLeft
attribute set to the @drawable/person_resized
:
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/MyRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selection 1"
android:textSize="24dp"
android:drawableLeft="@drawable/person_resized"
android:drawablePadding="5dp" />
</RadioGroup>
drawable/person_resized.xml
is a layer-list drawable that I used to downsize the drawable/person.png
image:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/person"
android:width="22dp"
android:height="22dp" />
</layer-list>
When this view is displayed on an Android N emulator, it behaves properly. But in my Android Kitkat(4.4.4) device the image is not properly sized.
Here is what I get in Android N:
And here is what I get in Android Kitkat:
What is going on here?
I have tried the following methods to downsize the drawableLeft
in Android Kitkat and none of them worked:
Using a ScaleDrawable to scale down the drawable while making sure to
SetLevel
, this actually allows to resize the drawable but without control; the resized image is always the same smaller size no matter what scaling factor I supplyGetting the bitmap from the drawable, resize it and create a new Bitmap drawable, but this makes the image disappear
Using an inset drawable, same as using a layer-list makes the image appear in its original size