2012-03-19 52 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