1

I have defined a custom background to RadioButton in my project so that I can change it in the java code. The background is a Layer-list that includes 2 items: XML drawable and image.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/colorAccent"/>
            <size android:width="20dp" android:height="20dp"/>
            <corners android:radius="3dp"/>
        </shape>
    </item>
    <item
        android:id="@+id/correct"
        android:drawable="@drawable/correct_image"
        android:height="15dp"
        android:width="15dp"
        android:gravity="center"/>
</layer-list>

The design will break because the height and width are not supported prior to API 23. Is there any way that I can set the size of the image programatically using dimension value? I don't have any prior coding experience or knowledge, so any explanation provided with possible solution will be very helpful. Thank you

3uday
  • 13
  • 3
  • 1
    In earlier Android versions you can set the width/ height with the size tag, for 23+ you set them as attributes of the item tag as I had to discover some time ago, see this [SO post](https://stackoverflow.com/a/39413168/5015207) – Bö macht Blau Apr 12 '18 at 18:03
  • @0X0nosugar It doesn't work because I'm using an image here not shape as an item – 3uday Apr 22 '18 at 13:32

0 Answers0