TableLayout 简单的记录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012153184/article/details/54022579

TableLayout 简单的记录

一下是tablelayout的主要的属性:

  • android:shrinkColumns ——-设置可收缩的列
  • android:stretchColumns ——设置可伸展的列
  • android:collapseColumns ——设置要隐藏的列(索引列从0开始)

内部的TableRaw的属性内部控件属性:

  • android:layout_column ——-该单元格在第几列显示
  • android:layout_span ——-该单元格占据列数,默认为1

这里写图片描述

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:shrinkColumns="0,1"
        >
        <Button android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="我独自站一行"
            />

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="0000000000000000000000000"
                />

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="1111111111111111111111111111111111111"
                />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="22222222222222
                                22222222"
                />

            <Button android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textAllCaps="false"
                android:text="match_parent"
                />

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2"
                />

        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2"
                />

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2"

                />
        </TableRow>

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="span=3"
                android:textAllCaps="false"
                android:layout_span="3"
                />

        </TableRow>
    </TableLayout>

    <TableLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:stretchColumns="1"
        >

        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="2"
                />

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAllCaps="false"
                android:text="stretchColumns=1"

                />

        </TableRow>
    </TableLayout>
</LinearLayout>

猜你喜欢

转载自blog.csdn.net/u012153184/article/details/54022579