android - Android 中的表格布局问题?

标签 android tablelayout tablerow

我使用了表格布局。它有两列。第一列包含一个 TextView ,另一个是 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>

最佳答案

没有错误,这正是 TableLayout 的用途。如果您不希望列具有相同的宽度,请从表格中取出第三行并将其放入自己的水平 LinearLayout 中。

(顺便说一句,您在示例中混淆了列和行。应该说:

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

关于android - Android 中的表格布局问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2966245/

相关文章:

android - 表格布局中的行之间的分隔

Android - TextView 和 Togglebutton 之间的空间?

android - 如何动态复制特定的表行

Android Idea测试报错信息: Unable to attach test reporter to test framework android

java - 用.(点)字符分割字符串java android

android - 从 EditText 保存文本

java - 为什么每次打开 Activity 时整型变量不会加 1?

css - MVC3 - 从脚手架结果创建列布局的最佳方法

Android TableRow RelativeLayout 问题

android - 单击表行时突出显示并在单击下一行时禁用