Android table layout Android:collapsecolumns,android:shrinkcolumns and Stretchcolumn

Source: Internet
Author: User

Android table layout Android:collapsecolumns,android:shrinkcolumns and stretchcolumn-zj0078 columns-Blog channel-csdn.net

The number of rows for a tablelayout is specified directly by the developer, that is, how many TableRow objects (or view controls) there are.

?? ? ? ? The number of columns of tablelayout equals the number of columns of TableRow that contain the most child controls. If the first TableRow contains 2 child controls, the second TableRow contains 3, and the third TableRow contains 4, then the Tablelayout has a number of 4 columns.



?

Tablelayout properties that can be set include global properties and cell properties.

1, global properties, or column properties, have the following 3 parameters:

android:stretchcolumns? Sets the columns that can be stretched. The column can stretch to the row direction, up to a full row.

android:shrinkcolumns?? Sets the columns that can be shrunk. When the column control has too much content and is already packed in the row, the contents of the child control are displayed in the columns direction.

Android:collapsecolumns sets the columns to hide.


example:

android:stretchcolumns= "0"????? No. 0 column can stretch

android:shrinkcolumns="???? 1th, 2 columns can be shrunk

android:collapsecolumns= "*"???? Hide all rows

2, cell properties, have the following 2 parameters:

Android:layout_column? Specifies that the cell is displayed in the first column

Android:layout_span??? Specifies the number of columns that the cell occupies (1 if unspecified)

Example:

android:layout_column= "1"? The control is displayed in the 1th column

Android:layout_span= "2"???? The control occupies 2 columns

Description: A control can also have both features.





?
<?xml version= "1.0" encoding= "Utf-8"?
? <tablelayout xmlns:android= "Http://schemas.android.com/apk/res/android"?
?????????????? android:layout_width= "Fill_parent"?
?????????????? android:layout_height= "Fill_parent"?
?????????????? >?
???? <tablerow>?
???? <button??
???????? android:id= "@+id/button1"?
???????? android:layout_width= "wrap_content"?
???????? android:layout_height= "wrap_content"?????????????
???????? android:text= "Button1"?
???????? android:layout_column= "0"/>?
????? <button??
????????? android:id= "@+id/button2"?
????????? android:layout_width= "Wrap_content"?
????????? android:layout_height= "Wrap_content"?
????????? android:text= "Hello, I am a Button2"?
????????? android:layout_column= "1"/>?
???? </tablerow>?
? </tablelayout>??

?

?

1?android:stretchcolumns = "specified column"?-------> to fill the specified column with a blank part in the No. 0 action order

Set stretchcolumns=0, the result is as follows, the No. 0 column is populated as far as possible

Set Stretchcolumns=1, the result is as follows, the 1th column is populated as far as possible


?

2?android:shrinkcolumns = "specified column": Automatically extends the specified column to fill the available parts with the No. 0 action order

Shrinkcolumns does not work when the controls inside the Layoutrow are not covered by the layout, such as

When the controls inside the Layoutrow are not covered by the layout (rewrite the contents of the third button)

3 Android:collapsecolumns = "specified column"? No. 0 Act, hide specified columns >

Android:collapsecolumns when this property is empty, such as:

android:collapsecolumns= "0" means to remove the No. 0 column, such as:

Android table layout Android:collapsecolumns,android:shrinkcolumns and Stretchcolumn

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.