<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width= "fill_parent"
android:layout_height= "50dip"
android:orientation="horizontal"
android:layout_gravity="center"
android:background="@drawable/squareback">
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/meleeRadio"
android:layout_width="150dip"
android:layout_height="40dip"
android:checked="false"
android:text="Melee Attack" android:textColor="@color/black" android:gravity="center" android:layout_gravity="center" android:layout_margin="5dip"/>
<RadioButton
android:id="@+id/rangeRadio"
android:layout_width="150dip"
android:layout_height="40dip"
android:text="Range Attack" android:textColor="@color/black" android:gravity="center" android:layout_gravity="center" android:layout_margin="5dip" android:checked="false"/>
</RadioGroup>
</LinearLayout>
To align them, I placed them in a LinearLayout, for which I set the size. Then I have android: layout_gravity = "center", which aligns the center for the elements. Therefore, even if the button and the text do not have the same size, they look good imo.
maebe source
share