android表格布局rowspan

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2189986/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 04:53:13  来源:igfitidea点击:

android table layout rowspan

androidtablelayouthtml-table

提问by d-man

I want to build the following layout but it is not working.

我想构建以下布局,但它不起作用。

alt text http://toms-toy.de/rowspan.gif

替代文字 http://toms-toy.de/rowspan.gif

<LinearLayout android:orientation="horizontal"...>
  <ImageView ...></ImageView>
        <TableLayout ...>
                        <TableRow..>
                              <ImageView ...></ImageView>
                              <ImageView ...></ImageView>
                              <ImageView ...></ImageView>
                        </TableRow>
                         <TableRow..>
                              <ImageView ...></ImageView>
                              <ImageView ...></ImageView>
                              <ImageView ...></ImageView>
                        </TableRow>
       </TableLayout>
  <ImageView ...></ImageView>
</LinearLayout>

回答by jeffh

I put this together really fast, try this:

我把它放在一起非常快,试试这个:

alt text

替代文字

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">
    <ImageView android:layout_width="50dip" android:layout_height="100dip" android:background="#cc0000"/>
    <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
        <TableRow>
            <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/>
            <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/>
            <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/>
        </TableRow>
        <TableRow>
            <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/>
            <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#aaaa00"/>
            <ImageView android:layout_width="50dip" android:layout_height="50dip" android:background="#00aa00"/>
        </TableRow>
    </TableLayout>
    <ImageView android:layout_width="50dip" android:layout_height="100dip" android:background="#cc0000"/>
</LinearLayout>

回答by delger

try out this:

试试这个:

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TableRow>
        <TextView android:text="1-2, 1;\t" android:layout_gravity="center" />
        <TableLayout>
            <TableRow>
                <TextView android:text="1, 2;\t" android:layout_gravity="center" />
            </TableRow>
            <TableRow>
                <TextView android:text="2, 2;\t" android:layout_gravity="center" />
            </TableRow>
        </TableLayout>
    </TableRow>
</TableLayout>

回答by user3702684

The output of the below code

下面代码的输出

enter ima,ge description here

在此处输入 ima,ge 描述

By Default the android doesn't have any attribute called rowspan but the below code works fine and created the row span.

默认情况下,android 没有任何名为 rowspan 的属性,但下面的代码工作正常并创建了行跨度。

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
    <TableRow>
        <TextView
            android:text="Hello"
            android:textSize="30dp"
            />
        <TextView
            android:text="Hello World"
            android:textSize="30dp"
            android:background="@drawable/border"

            />
        <Button android:text="Click me"
            android:textSize="30dp"/>

    </TableRow>

    <TableRow>
        <TextView
            android:text="Hello"
            android:textSize="30dp"
            />
           <Button android:text="Click"
            android:textSize="30dp"
               android:layout_column="2"/>

    </TableRow>
    <TableRow>
        <TextView
            android:text="Hello"
            android:textSize="30dp"
            />
        <TextView
            android:text="Hello"
            android:textSize="30dp"
            />
        <Button android:text="Click me"
            android:textSize="30dp"/>

    </TableRow>
    <TableRow>
        <TableLayout
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:layout_span="2">
            <TableRow>
                <Button android:text="1"/>
                <Button android:text="2"/>
            </TableRow>
            <TableRow>
                <Button android:text="3"/>
                <Button android:text="4"/>
            </TableRow>

        </TableLayout>
        <Button
            android:layout_height="match_parent"
            android:layout_width="wrap_content"
            android:text="Enter"
            android:background="#ff0099"/>
    </TableRow>
</TableLayout>