TableLayout和TableRow容器在API中的描述

<span style="font-family: Arial, Helvetica, sans-serif;">A layout that arranges its children into rows and columns. A TableLayout consists of a number of TableRow objects, each defining a row (actually, you can have other children, which will be explained below). TableLayout containers do not display border lines for their rows, columns, or cells. Each row has zero or more cells; each cell can hold one View object. The table has as many columns as the row with the most cells. A table can leave cells empty. Cells can span columns, as they can in HTML.</span>

        TableLayout容器把他的子控件按照行列的形式排列。一个TableLayout容器可以包含多个TableRow容器对象,每一个TableRow对象表示一行(实际使用中,也可以使用TableRow以外的控件或容器做为一行,后面会说到)。TableLayout容器不显示行、列或者格子之间的边界线。每一行包含零或者多个格子,每个格子只能包含一个视图对象。表格拥有的列数由表格中格子最多的一样来决定,格子可以为空白--即不包含任何视图对象。格子和HTML中的格子一样是可以横跨多列的。

The width of a column is defined by the row with the widest cell in that column. However, a TableLayout can specify certain columns as shrinkable or stretchable by calling setColumnShrinkable() or setColumnStretchable(). If marked as shrinkable, the column width can be shrunk to fit the table into its parent object. If marked as stretchable, it can expand in width to fit any extra space. The total width of the table is defined by its parent container. It is important to remember that a column can be both shrinkable and stretchable. In such a situation, the column will change its size to always use up the available space, but never more. Finally, you can hide a column by calling setColumnCollapsed().
        列宽,是由这一列的最宽的那个格子决定的。然而,TableLayout可以提供方法来指定某一列的格式是可以自行伸展(setColumnStrectchable(int column , boolean strectchable)或者收缩(setColumnShrinkable(int column, boolean shrinkable)。如果设置某一列为可以收缩的,这一列的列宽就可以自动收缩来维持表格的宽度能够适应TableLayout对象的父容器指定的宽度;同样,如果设置某一列可以伸展的,这一列的列宽就可以自动伸展填充剩余空间来维持表格的宽度能够适应TableLayout对象的父容器指定的宽度;表格的宽度由TableLayout的对象的父容器指定。记住,表格的列可以同时设置为可伸展和可伸缩,这样,这一列就可以通过伸展和收缩动作使得父容器为表格指定的宽度空间恰好用完,不会有剩余。TableLayout可以使用setColumnCollapsed(int column, boolean isCollapsed)来设定某一列是的隐藏属性(如果参数isCollapsed的值为true,这一列将不会出现在屏幕上)。

The children of a TableLayout cannot specify the layout_width attribute. Width is always MATCH_PARENT. However, the layout_height attribute can be defined by a child; default value is ViewGroup.LayoutParams.WRAP_CONTENT. If the child is a TableRow, then the height is always ViewGroup.LayoutParams.WRAP_CONTENT.
        TableLayout的子控件不能设置layout_width属性。子控件的宽度总是取MATCH_PARENT值。然而,子控件的layout_height属性时可以设置的;layout_height的默认值是WRAP_CONTENT。如果子控件是TableRow对象,layout_height的值总是取WRAP_CONTENT值。

Cells must be added to a row in increasing column order, both in code and XML. Column numbers are zero-based. If you don't specify a column number for a child cell, it will autoincrement to the next available column. If you skip a column number, it will be considered an empty cell in that row. See the TableLayout examples in ApiDemos for examples of creating tables in XML.
        格子必须被添加到行内,增加一行的列数,这可以在XML文件或者Java源码中实现。列号是从零开始的。若果不为新的格子指定列号,那么它将被放置在这一行最后一个格子的后面,成为这一行新的末尾格子。若果在设置格子列号时,跳过了一个或多个列号,那么这一个或多个列在这一行上被设置为空格子。在XML布局中创建表格的例子可以再ApiDemos(注:ApiDemos是android sdk中提供的示例工程)工程中找到。

Although the typical child of a TableLayout is a TableRow, you can actually use any View subclass as a direct child of TableLayout. The View will be displayed as a single row that spans all the table columns.
        虽然表格布局TableLayout代表性的子控件是TableRow,实际上也可以指定View类的任意子类对象作为TableLayout对象的直接子控件。这个非TableRow子控件会单独显示为一行,横跨所有列。



---------------------------------------------TableRow-------------------------------------------------------------

A layout that arranges its children horizontally. A TableRow should always be used as a child of a TableLayout. If a TableRow's parent is not a TableLayout, the TableRow will behave as an horizontal LinearLayout.

The children of a TableRow do not need to specify the layout_width and layout_height attributes in the XML file. TableRow always enforces those values to be respectively ViewGroup.LayoutParams.MATCH_PARENT and ViewGroup.LayoutParams.WRAP_CONTENT.
        TableRow容器总是横向的排列他的子控件。TableRow应该作为TableLayout的子控件使用,如果TableRow的父容器不是TableLayout,那么TableRow将退化为一个横向排列的LinearLayout。

        在XML布局中TableRow的子控件不需要指定layout_width和layout_height。TableRow总是强制设置为MATCH_PARENT或者WRAP_CONTENT值。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值