Explain Android tablelayout table layout in detail

The label of table layout is tablelayout, which inherits LinearLayout. So it is still a linear layout.

preface:

1. Introduction to tablelayout

2. Determining the number of rows and columns in tablelayout

3. Detailed explanation of settable properties of tablelayout

4. An example and renderings of four tablelayout layouts

1、 Introduction to tablelayout

The tablelayout class manages controls in the form of rows and columns. Each row is a tablerow object or a view control. When it is a tablerow object, you can add child controls under the tablerow. By default, each child control occupies a column. When it is a view, the view will monopolize one row.

2、 Determining the number of rows and columns in tablelayout

The number of rows of tablelayout is directly specified by the developer, that is, there are as many rows as there are tablerow objects (or view controls).

The number of columns in a tablelayout is equal to the number of columns in a tablerow with the most child controls. If the first tablerow contains 2 child controls, the second tablerow contains 3, and the third tablerow contains 4, the number of columns in the tablelayout is 4

3、 Detailed explanation of settable properties of tablelayout

The properties that tablelayout can set include global properties and cell properties.

1. The global attribute, that is, the column attribute, has the following three parameters:

Android: stretchcolumns sets stretchable columns. The column can extend in the direction of a row and occupy up to an entire row.

Android: shrinkcolumns sets shrinkable columns. When the content of the column child control is too much and has been crowded with the row, the content of the child control will be displayed in the column direction.

Android: columnsecolumns sets the columns to hide.

Example:

Android: stretchcolumns = "0" column 0 is stretchable

Android: shrinkcolumns = "1,2" columns 1 and 2 can be shrunk

Android: columnsecolumns = "*" hide all rows

Note: a column can have stretchcolumns and shrinkcolumns attributes at the same time. If so, when the column has more than N contents, its contents will be displayed in "multiple rows". (this is not a real multi line, but the system automatically adjusts the layout_height of the line as needed)

2. Cell properties have the following 2 parameters:

android:layout_ Column specifies the column in which the cell displays Android: layout_ Span specifies the number of columns occupied by the cell (1 if not specified)

Example:

android:layout_ Column = "1" the control is displayed in column 1 Android: layout_ Span = "2" the control occupies 2 columns

Note: a control can also have these two features at the same time.

The above content is the Android tablelayout table layout introduced by xiaoforced. I hope it will be helpful to you!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>