Explain in detail the usage of stretchcolumns and shrinkcolumns in Android tablelayout

Explain in detail the usage of stretchcolumns and shrinkcolumns in tablelayout in Android

Android: stretchcolumns = "1" Android: shrinkcolumns = "1" these two attributes are unique to tablelayout, and they also affect the layout of child objects.

Table layout is a layout that organizes sub views by rows and columns. The table layout contains a series of tabrow objects that define rows (other sub objects can also be used). A table layout does not display table lines for its rows, columns, and cells. Each row can contain more than (including) cells; A view object can be set for each cell. Just as a row contains many cells, a table contains many columns. Table cells can be empty.

The width of a column is determined by the widest cell in all rows of the column. However, the table layout can be marked with two properties: shrinkcolumns and stretchcolumns. Some columns can shrink or stretch. If marked as shrinkable, the column width can shrink to make the table fit the size of the container. If marked as stretchable, the column width can be stretched to take up extra space. The total width of a table is determined by its parent container. Remember that columns can have both stretchable and shrinkable properties. Finally, you can hide columns by setting the columnecolumns property.

Child objects of table layout cannot specify Android: layout_ Width attribute. Width is always "match_parent". However, child objects can define Android: layout_ Height attribute; Its default value is wrap_ Content. If the child object is a tablerow, its height is always wrap_ content。

Although the typical sub object of table layout is table row, in fact, you can use the sub class of any view class as the direct sub object of table view. The view will be displayed as a cell with only one row and combined with all columns. Android: stretchcolumns = "1" set the second column of the row used as an extended column. If there are three columns, the remaining space is filled by the second column.

Similarly, Android: stretchcolumns = "0" sets the second column of the row used as the extended column

Android: shrinkcolumns = "1" set the second column of the row to be used as the shrink column

Thank you for reading, hope to help you, thank you for your support to this site!

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
分享
二维码
< <上一篇
下一篇>>