Android中的表格布局问题?

时间:2010-06-03 13:14:34

标签: android tablelayout tablerow

我使用了表格布局。它有两列。第一列包含文本视图,另一列是EditText。我的布局应该是这样的。

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>

1 个答案:

答案 0 :(得分:3)

毫无疑问,完全是TableLayout的意图。如果您不希望列具有相同的宽度,请将第三行从表中取出并将其放入其自己的水平LinearLayout中。

(顺便说一下,你的例子中的列和行之间已经混淆了。应该说:

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