A018-布局之TableLayout

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为序,当控件布满布局时,指定列自动填充可用部分。

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

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

layout_column属性:以0行为序,设置组件显示指定列。

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

示例代码:

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

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-05 07:09:27

A018-布局之TableLayout的相关文章

Android UI布局之TableLayout

从字面上了解TableLayout是一种表格式的布局.这样的布局会把包括的元素以行和列的形式进行排列.表格的列数为每一行的最大列数.当然表格里边的单元格是能够为空的. 实例:LayoutDemo 执行效果: 代码清单: 布局文件:table_layout.xml <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android

Android 布局详解 -三表格布局(TableLayout)以及重要属性

三表格布局(TableLayout)以及重要属性             TableLayout跟TableRow 是一组搭配应用的布局,TableLayout置底,TableRow在TableLayout的上方,而Button.TextView等控件就在TableRow之上,别的,TableLayout之上也可以零丁放控件.TableLayout是一个应用错杂的布局,最简单的用法就仅仅是拖沓控件做出个界面,但实际上,会经常在代码里应用TableLayout,例如做出表格的结果.本文首要介绍Ta

Android 布局之TableLayout

1 TableLayout简介 TableLayout是表格布局.TableLayout 可设置的属性包括全局属性及单元格属性. 1.1 全局属性 有以下3个参数: android:stretchColumns 设置可伸展的列.该列可以向行方向伸展,最多可占据一整行.android:shrinkColumns 设置可收缩的列.当该列子控件的内容太多,已经挤满所在行,那么该子控件的内容将往列方向显示.android:collapseColumns 设置要隐藏的列. 示例: android:stre

Android的学习第六章(布局一TableLayout)

今天我们来简单的说一下Android不居中的TableLayout布局(表格布局) 表格布局的意思就是将我们的布局看做为一个表格,主要用于对控件进行整齐排列 我们看一个简单的案例 <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width=&q

Android:控件布局(表格布局)TableLayout

摘录自:http://www.cnblogs.com/tinyphp/p/3812486.html TableLayout继承LinearLayout 有多少个TableRow对象就有多少行, 列数等于最多子控件的TableRow的列数 直接在TableLayout加控件,控件会占据一行 TableLayout属性(也叫全局属性):*代表所有列 android:shrinkColumns -------设置可收缩的列,(内容过多,则收缩,扩展到第二行,控件没布满TableLayout时不起作用)

35、键盘布局的tableLayout备份

<TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_marginBottom="200dp" a

Android【布局管理器语法】之四大布局【LinearLayout,TableLayout,FrameLayout,RelativeLayout】

LinearLayout 线性布局是将放入其中的组件按照垂直(vertical)或者水平(horizontal)方向来布局, 也就是控制其中组件横向排列或者纵向排列.在线性布局中 每一行[针对垂直排列]或每一列[针对水平排列]只能放一个组件 . 注意:Android线性布局不会换行,当组件一个挨着一个排列到窗体边缘后 剩下的组件将不会显示出来 排列方式由android:orientation属性控制,对齐方式由android:gravity属性来控制 (1)常见属性: android:orien

布局与控件(六)-TableLayout和VideoView

第7节 TableLayout TableLayout顾名思义,就是像表格一样的布局.它是LinearLayout的子类,所以拥有TableLayout的所有属性. 7.1 TableLayout的行数 TableLayout需要与它的搭档TableRow配合使用,TableRow也是LinearLayout的子类,表示表格的每一行,例如一个表格有3行,它的布局文件就应该像这样, <TableLayout android:layout_height="match_parent"

Android UI布局TableLayout

了解字面上TableLayout一个表格样式布局.这种布局将包括以行和列的形式的元件被布置.表格列的数目是列的各行中的最大数目.当然,表格里面的单元格它能够清空. 实例:LayoutDemo 执行效果: 代码清单: 布局文件:table_layout.xml <? xml version="1.0" encoding="utf-8"? > <TableLayout xmlns:android="http://schemas.android

UI组件:布局管理器

一.线性布局(LinearLayout) 线性布局可以让布局中的组件一个接着一个的连在一起水平对齐(orientation="vertical")或者垂直对齐(orientation="horizontal"),写游戏界面时会限制动作,所以不推荐游戏界面中使用 特点:线性布局不会主动换行,当几个组件水平分布,但是这一行放不下时,多余的不会显示 二.绝对布局(AbsoluteLayout) 绝对布局没有布局控制,组件的大小和位置全部由开发人员用x,y坐标来一一定义,由