2012-03-19 80 views
0

enter image description here嗨,Android - UI问题

我需要设计一个类似于我的附加图像的用户界面。我需要设置TextView的帮助,例如它与单选按钮居中对齐。 TextView的中心位置和单选按钮的中心位置应该在同一条垂直线上。

+1

用相对的观点。 – L7ColWinters 2012-03-19 06:42:05

+2

使用相对布局,并提出问题之前做一些谷歌搜寻,,, – 2012-03-19 06:43:59

+0

你可以请任何样品? – Prem 2012-03-19 06:44:03

回答

1

您可以使用相对布局这样,

<?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> 
+0

谢谢,但它不会工作。如果Textview的长度比单选按钮长,那么单选按钮应该位于textview的中间。在这段代码中,如果textview的长度很长,Text移动到下一行 – Prem 2012-03-19 07:12:07

+0

在用户界面模式下拖动和对齐 – drulabs 2012-03-19 07:14:59

+0

如果我这样做,视图在不同的屏幕尺寸上看起来不一致。 – Prem 2012-03-19 07:22:25