Reputation: 11669
Although this Q&A has been checked, the text cannot be aligned left to a RadioGroup in Android.
Current Outcome
Expected Outcome
Code
C:\workspace-adt\Helloworld\res\layout\activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.helloworld.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:text="@string/fractions" />
<RadioGroup
android:id="@+id/fractions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/fraction_true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:paddingRight="15dip"
android:text="@string/fraction_true" />
<RadioButton
android:id="@+id/fraction_false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="15dip"
android:text="@string/fraction_false" />
</RadioGroup>
</RelativeLayout>
C:\workspace-adt\Helloworld\res\values\strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Helloworld</string>
<string name="fractions">Fractions</string>
<string name="action_settings">Settings</string>
<string name="fraction_true">True</string>
<string name="fraction_false">False</string>
</resources>
Upvotes: 0
Views: 96
Reputation: 15767
use Linear Layouts
with weight
.which will make it simple
check docs
or with just LinearLayout
<LinearLayout
android:id="@+id/linearLayout5"
android:layout_width= "fill_parent"
android:orientation="horizontal"
android:layout_gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:text="@string/fractions" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/fraction_true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:paddingRight="15dip"
android:gravity="center"
android:layout_gravity="center"
android:text="lalalal" />
<RadioButton
android:id="@+id/fraction_false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="15dip"
android:gravity="center"
android:layout_gravity="center"
android:text="lalalal" />
</RadioGroup>
</LinearLayout>
Upvotes: 1
Reputation: 621
Seems like a case for an horizontal linear layout.
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:text="lalalal" />
<RadioGroup
android:id="@+id/fractions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/fraction_true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:paddingRight="15dip"
android:text="lalalal" />
<RadioButton
android:id="@+id/fraction_false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="15dip"
android:text="lalalal" />
</RadioGroup>
</LinearLayout>
Upvotes: 2