Reputation: 4821
Hi,
I need to design an UI similar to my attached image. I need help on setting the TextView such as it is center aligned with radiobuttons. The center position of TextView and center position of radiobutton should be in same vertical line.
Upvotes: 0
Views: 98
Reputation: 34301
You can use relative layout like this,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center"
android:orientation="vertical">
<RelativeLayout android:id="@+id/rlCell"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<RadioButton android:text="" android:gravity="center_vertical|center_horizontal" android:id="@+id/radioButton1" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
<TextView android:layout_below="@+id/radioButton1" android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="TextView" android:layout_alignLeft="@+id/radioButton1" android:layout_alignRight="@+id/radioButton1"></TextView>
<RadioButton android:text="" android:layout_toRightOf="@id/radioButton1" android:id="@+id/radioButton2" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
<TextView android:layout_below="@+id/radioButton2" android:id="@+id/textView2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="TextView" android:layout_alignLeft="@+id/radioButton2" android:layout_alignRight="@+id/radioButton2"></TextView>
</RelativeLayout>
</LinearLayout>
Upvotes: 1