2010-06-03 53 views
2

我已經使用表格佈局。它有兩列。第一列包含一個文本視圖,另一個是EditText。我的佈局應該看起來像這樣。Android中的表格佈局問題?

column1: columnvalue1 
column2: columnvalue2 
col3: columnvalue3 

但我的佈局汽車這樣排列:

column1: columnvalue1 
column2: columnvalue2 
col3: columnvalue3 

如何解決像第一個佈局。它有什麼錯誤?任何想法?

代碼:我注意到單行的代碼。以供參考。就像我爲所有行所做的代碼一樣。

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="wrap_content" android:layout_height="fill_parent" 
      android:stretchColumns="1" android:background="@drawable/corner_white" 
      android:layout_margin="10dip"> 
<TableRow android:orientation="horizontal" 
       android:minHeight="50dip" android:gravity="center_vertical"> 
       <TextView android:text="@string/ename" android:textSize="15sp" 
        android:textColor="@color/black" android:padding="10dip" /> 
       <EditText android:id="@+id/ename_value" android:textSize="15sp" 
        android:inputType="textEmailAddress" android:background="@null" 
        android:singleLine="true" /> 
      </TableRow> 
     </TableLayout> 

回答

3

有沒有搞錯,這是正是什麼TableLayout的意思做。如果不希望列具有相同的寬度,請將第三行從表中取出並放入其自己的水平LinearLayout中。

(而且,順便說一下,你也得爲自己混在你的例子列和行之間應該說:

row1: row1 value 
row2: row2 value 
r3: row3 value