Reputation: 581
As i was developing an app and i needed radio buttons, i decided to create a RadioGroup
and inside it, i created 3 RadioButton
s and i wanted to position them to the left, center, and right accordingly.
I put android:orientation:"horizontal"
in RadioGroup
and i have placed android:layout_gravity="left
right or center in RadioButton
s created inside RadioGroup, but it just places the buttons next to each other aligned left, and distorts the text a little bit.
Same thing happens if i apply android:gravity="left"
to the buttons.
I am not sure how to align first button on the left side, second on the center, and third on the right side.
Thanks!
Upvotes: 2
Views: 2651
Reputation: 5220
try this in your layout :
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:orientation="horizontal">
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="1"/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="2"/>
<RadioButton
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="3"/>
</RadioGroup>
Upvotes: 3