1

In my app i am using a radio button.The radio button may contain text or images. I am setting the width of radio button to match_parent.For texts it works fine but for images, the images are going to the end. I am setting the images programatically using setIntrinsicBound().I want the image to appear from start.

Code

rbOption1.setCompoundDrawablesWithIntrinsicBounds(0, 0, imageOpt1, 0);

Xml

            <RadioButton
                android:id="@+id/rb_option1"
                style="@style/text_view_style"
                android:layout_width="match_parent"
                android:layout_height="0dp"       
                android:layout_weight="1"
                android:checked="false"
                android:text=""
                android:textSize="16sp"
                android:visibility="visible" />
Archana Vetkar
  • 63
  • 2
  • 11

1 Answers1

0

You should set the image using below code rbOption1.setCompoundDrawablesWithIntrinsicBounds(imageOpt1,0,0,0);

You can refer this for more info How to programmatically set drawableLeft on Android button?

Community
  • 1
  • 1
Sandeep
  • 1,814
  • 21
  • 25
  • In your code you have set the resource id as 3rd parameter. It should be first parameter. Check your posted code. – Sandeep Sep 07 '15 at 07:20