1

I have a radio button, with the text on the left and the actual button on the right.
I want to add a multi-line string as text but when I do the button is always aligned to the center of the text. Is there a way for me to choose exactly where it is placed instead?
enter image description here

<RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@color/white"
        >

        <RadioButton
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:textSize="@dimen/text_size"
            android:minHeight="60dp"
            android:text="@string/multilinestring"

            android:button="@null"
            android:drawableRight="@drawable/btn_radio_holo_light" />

 </RadioGroup>

Update:
Using <RadioGroup><RelativeLayout> seems to do the trick but when adding more radio buttons they stop behaving as a group.

I mean:

<RadioGroup>  
   <RelativeLayout>  
      <TextView> </TextView>  
      <RadioButton></RadioButton>  
   </RelativeLayout>  
   <RadioButton></RadioButton>  
<RadioGroup>

This allows me to set the button where I want but then the 2 radio buttons don't behave as part of the same group. I can have both clicked/selected at the same time

Community
  • 1
  • 1
Jim
  • 18,826
  • 34
  • 135
  • 254
  • Can you also post your layout file to show how you are making above layout? – Sharjeel Aug 17 '15 at 18:21
  • @Sharj:Please see update – Jim Aug 17 '15 at 18:23
  • if you want your radioButtons to behave as a group inside a relativeLayout check my answer here: https://stackoverflow.com/questions/10461005/how-to-group-radiobutton-from-different-linearlayouts/56050654#56050654 – med.Hamdan May 10 '19 at 02:44

1 Answers1

0

You can change button position by specifying button position. Like

android:button="@null"
android:drawableBottom="@android:drawable/checkbox_off_background"

It will draw button at bottom of text. You can use more options like android:drawableRight, android:drawableLeft, android:drawableTop, android:drawableEnd, android:drawableStart, android:drawablePadding to change position of button.

Hari Ram
  • 3,098
  • 5
  • 23
  • 30
  • I want the button to the right. Just not in the center. I want to be able to set it either right/top or right/bottom of text (I mean align top/bottom with text) – Jim Aug 17 '15 at 18:21
  • I have tried but not able to do. You can try various combinations with gravity and if you get it right then you are lucky. – Hari Ram Aug 17 '15 at 18:33