Android7.0中文API -- TableLayout

完整内容请查看:http://www.zhdoc.net/android/reference/android/widget/TableLayout.html

TableLayout

public class TableLayout
extends LinearLayout

java.lang.Object
   ↳android.view.View
    ↳android.view.ViewGroup
     ↳android.widget.LinearLayout
      ↳android.widget.TableLayout


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.
一种布局,其将子项放置到行和列中。一个TableLayout由一组TableRow对象组成,其定义了每一行(事实上,你可以拥有其他子项,下面将会解释)。TableLayout容器不显示它们的行、列或单元格的边框。每一行都拥有0个或多个单元格;每个单元格都含有一个View对象。表格是由一些列和行组成的单元格。表格可以清空单元格。单元格可以跨列,就像在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可以通过调用setColumnShrinkable()setColumnStretchable()来指定某些列是可收缩的或可拉伸的。如果标记为可收缩,则列的宽度可以被缩小,以便将表放入其父对象中。如果标记为可拉伸,则它可以扩大宽度以适应任何额外的空间。表的总宽度由它的父容器定义。请记住,一个列既可以收缩,也可以拉伸。在这种情况下,该列将改变其大小,使其始终占用可用空间,但不会更多。最后,可以通过调用setColumnCollapsed()来隐藏一列。

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 WRAP_CONTENT. If the child is a TableRow, then the height is always WRAP_CONTENT.
TableLayout的子项不能指定layout_width属性。宽度始终是MATCH_PARENT。但是,layout_height属性可以由子项来定义;默认值为WRAP_CONTENT。如果子项是一个TableRow,则其高度始终是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中。列号是从零开始的。如果你没有指定子单元格的列号,它将自动增加到下一个可用列。如果你跳过了一个列号,那这个列号将被认为是该行中的一个空单元。参考ApiDemos中的TableLayout的例子,其在XML中创建了表格。

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,但实际上可以使用任何视图子类作为TableLayout的直接子项。视图可以显示为一个横跨所有表列的单行。

摘要


嵌套类

classTableLayout.LayoutParams

This set of layout parameters enforces the width of each child to be MATCH_PARENT and the height of each child to be WRAP_CONTENT, but only if the height is not specified. 
这组布局参数将每个子项的宽度设置为MATCH_PARENT,并将每个子项的高度设置为WRAP_CONTENT,但前提是没有指定特定高度。 

XML属性

android:collapseColumns设置需要被收缩的列序号(序号从0开始)。 
android:shrinkColumns设置需要被收缩的列序号(序号从0开始)。 
android:stretchColumns设置需要被拉伸的列序号(序号从0开始)。 

继承XML属性

完整内容请查看:http://www.zhdoc.net/android/reference/android/widget/TableLayout.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值