Put a relative layout into the linear layout and place the radio buttons inside!
I always use relative layout, it is much more adaptive when you get used to the controls.
Question
I have 4 radio buttons. Under these buttons i want a text. The radio buttons should be in the center above the text. i tried to put them in a linear layout together (text and button) but then i loose the function of the radio group because the radio buttons must be the direct children of the radio group. How can i do this?
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radioButton0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" />
<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" />
<RadioButton
android:id="@+id/radioButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center" />
</RadioGroup>
<LinearLayout
android:id="@+id/container_timeline"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/seek_timeline_morning"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/timeline_morning" />
<TextView
android:id="@+id/seek_timeline_noon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/timeline_noon" />
<TextView
android:id="@+id/seek_timeline_evening"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/timeline_evening" />
<TextView
android:id="@+id/seek_timeline_night"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/timeline_night" />
</LinearLayout>
![enter image description here][1]
Solution
Put a relative layout into the linear layout and place the radio buttons inside!
I always use relative layout, it is much more adaptive when you get used to the controls.