I have a RadioGroup defined in XML that has two RadioButtons. However, I need to have the label displayed to the left of the button itself, with the label aligned left and the button aligned right. To do that, I used a RelativeLayout containing a TextView and a RadioButton with no text
. This is approximately what the layout looks like:
<RadioGroup android:id="@+id/foo" android:layout_height="wrap_content" android:layout_width="match_parent">
<RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent">
<TextView android:text="@string/bar_one" android:layout_alignParentLeft="true" android:layout_height="wrap_content" android:layout_width="wrap_content" />
<RadioButton android:id="@+id/bar1" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</RelativeLayout>
...
</RadioGroup>
That displays the way I expect but what I've found is that the RadioGroup allows more than one RadioButton to be selected. When I remove the RelativeLayouts and TextViews, so the RadioButtons are nested directly under the RadioGroup, only one can be selected. Is there a way to wrap my RadioButtons but keep more than one from being selected at the same time?
If not, is there a better way to accomplish the styling I'm after?