A018-布局之TableLayout

TableLayout

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

eg:三行三列的布局


<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为序,当控件布满布局时,指定列自动填充可用部分。
A018-布局之TableLayout_第1张图片

strechColumns属性,以第0行为序,指定列对空白部分进行填充。
A018-布局之TableLayout_第2张图片

collapseColumns属性:以0行为序,隐藏指定的列。
A018-布局之TableLayout_第3张图片

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

A018-布局之TableLayout_第4张图片

示例代码:


<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"
            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

你可能感兴趣的:(【Android开发记录】)