A018-布局之TableLayout

作者: IT_xiao小巫 | 来源:发表于2015-10-04 21:18 被阅读195次

TableLayout

表格布局,顾名思义像表格一样进行布局。我们通常配合TableRow一起使用,TableRow代表一行,有多少个TableRow就有多少行。

eg:三行三列的布局

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <TableRow>
        <Button android:text="Button1"/>
        <Button android:text="Button2"/>
        <Button android:text="Button3"/>
    </TableRow>
    <TableRow>
        <Button android:text="Button4"/>
        <Button android:text="Button5"/>
        <Button android:text="Button6"/>
    </TableRow>
    <TableRow>
        <Button android:text="Button7"/>
        <Button android:text="Button8"/>
        <Button android:text="Button9"/>
    </TableRow>
</TableLayout>

XML Attribute

shrinkColumns属性,以0为序,当控件布满布局时,指定列自动填充可用部分。


shrinkColumns属性shrinkColumns属性

strechColumns属性,以第0行为序,指定列对空白部分进行填充。


strechColumns属性strechColumns属性

collapseColumns属性:以0行为序,隐藏指定的列。


collapseColumns属性collapseColumns属性

layout_column属性:以0行为序,设置组件显示指定列。
layout_span属性:以第0行为序,设置组件显示占用的列数。

layout_column和layout_span属性layout_column和layout_span属性

示例代码:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    >
    <!-- android:shrinkColumns="2"
    以0为序,当控件布满布局时,指定列自动填充可用部分。
    strechColumns属性,以第0行为序,指定列对空白部分进行填充
    collapseColumns属性:以0行为序,隐藏指定的列
    -->
    <TableRow>
        <Button android:text="Button1"
            android:layout_span="3"/>
        <Button android:text="Button2"/>
        <Button android:text="Button3"/>
    </TableRow>
    <TableRow>
        <Button android:text="Button4"
            android:layout_column="1"/>
        <Button android:text="Button5"
            />
        <Button android:text="Button6"/>
    </TableRow>
    <TableRow>
        <Button android:text="Button7"/>
        <Button android:text="Button8"
            android:layout_column="2"/>
        <Button android:text="Button9"/>
    </TableRow>
</TableLayout>

转载请注明:IT_xiao小巫 http://blog.csdn.net/wwj_748

相关文章

  • A018-布局之TableLayout

    TableLayout 表格布局,顾名思义像表格一样进行布局。我们通常配合TableRow一起使用,TableRo...

  • Android之6大布局

    LineLayout (线性布局) RelativeLayout(相对布局) TableLayout(表格布局) ...

  • 2 布局

    LinearLayout(线性布局) RelativeLayout(相对布局) TableLayout(表格布局)...

  • Android学习笔记

    TableLayout 表格布局 AbsoulteLayout 绝对布局 FrameLayout 帧布局 Rela...

  • 基础布局

    Android中的布局 线性布局:LinerLayout 表格布局:TableLayout 相对布局:Relati...

  • 六、表格布局TableLayout

    表格布局由TableLayout所代表,表格布局采用行、列的形式来管理UI组件,TableLayout并不需要明确...

  • 2017年常见android面试题

    五大布局: LinearLayout线性布局FrameLayout层叠布局TableLayout 表格布局Abso...

  • Android学习笔记

    一、布局方式: (1)线性布局LinearLayout(2)表格布局TableLayout(3)帧布局FrameL...

  • TableLayout

    顾名思义,TableLayout可以用了创建类似表格的布局。但是,TableLayout是以多个TableRow为...

  • 零基础学鸿蒙编程-UI控件_TableLayout

    什么是TableLayout TableLayout又称表格布局,用于以表格形式展示内容. 1. 样例:2*2表格...

网友评论

    本文标题:A018-布局之TableLayout

    本文链接:https://www.haomeiwen.com/subject/rrvgcttx.html