在表格布局中跨 2 行拉伸

发布于 2024-10-08 21:56:34 字数 1546 浏览 1 评论 0原文

如何在 TableLayout 中拉伸两列。我有 2 行带有标签,并在 1 行上编辑文本,我希望有一个按钮横跨整个第二行。

<?xml version="1.0" encoding="utf-8"?>
<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent"
    android:background="#000000"
    android:stretchColumns="1">

    <TableRow>
        <TextView
            android:text = "Name: "  />
        <EditText
            android:id = "@+id/txtAddName"
            android:gravity = "right"
            android:layout_width = "fill_parent" />
    </TableRow>
    <TableRow>
        <TextView
            android:text = "Phone: "  />
        <EditText
            android:id = "@+id/txtAddPhone"
            android:gravity = "right"
            android:layout_width = "fill_parent" />        
    </TableRow>
    <TableRow>
        <Button
            android:id = "@+id/btnAdd"
            android:text = "Add Entrie"
            android:layout_width = "fill_parent" />
    </TableRow>
    <TableRow>
        <Button
            android:id = "@+id/btnShow"
            android:text = "Show all Entries"
            android:layout_width = "fill_parent" />
    </TableRow>
    <TableRow>
        <Button
            android:id = "@+id/btnDelete"
            android:text = "Delete all Entries"
            android:layout_width = "fill_parent" />
    </TableRow>
</TableLayout>

How do I stretch across 2 columns in the TableLayout. I have 2 rows with a label and edit text on 1 row and I want to have a single button stretch across the whole second row.

<?xml version="1.0" encoding="utf-8"?>
<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent"
    android:background="#000000"
    android:stretchColumns="1">

    <TableRow>
        <TextView
            android:text = "Name: "  />
        <EditText
            android:id = "@+id/txtAddName"
            android:gravity = "right"
            android:layout_width = "fill_parent" />
    </TableRow>
    <TableRow>
        <TextView
            android:text = "Phone: "  />
        <EditText
            android:id = "@+id/txtAddPhone"
            android:gravity = "right"
            android:layout_width = "fill_parent" />        
    </TableRow>
    <TableRow>
        <Button
            android:id = "@+id/btnAdd"
            android:text = "Add Entrie"
            android:layout_width = "fill_parent" />
    </TableRow>
    <TableRow>
        <Button
            android:id = "@+id/btnShow"
            android:text = "Show all Entries"
            android:layout_width = "fill_parent" />
    </TableRow>
    <TableRow>
        <Button
            android:id = "@+id/btnDelete"
            android:text = "Delete all Entries"
            android:layout_width = "fill_parent" />
    </TableRow>
</TableLayout>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文