3. tablelayout (Table layout)
Layout as a table, typically, Tablelayout has multiple TableRow, each tablerow a row.
<?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 " android: shrinkcolumns="2"> <TableRow> <button android:text= "Button1"/> < Button android:text= "Button2"/> <button android:text= "Button3"/> </TableRow> < tablerow> <button android:text= "Button4"/> <button android:text= "Button5"/> < Button android:text= "Button6"/> </TableRow> <TableRow> <button android:text= " Button7 "/> <button android:text=" Button8 "/> <button android:text= " Button9 "/> </ Tablerow></tablelayout>
Summary: Common properties:
[1]shrinkcolumns property: In 0, when the controls inside the TableRow are laid out, the specified columns are automatically extended to fill the available parts, and Shrinkcolumns does not work when the controls inside the TableRow are not covered by the layout. (android:shrinkcolumns="2", 3rd column filled with time )
[2] Strechcolumns Property: Specifies that the column fills the blank part with the No. 0 action order. (android:strechcolumns="2", 3rd column filled)
[3]collapsecolumns Property: Hides the specified column in 0 order. (android:strechcolumns="2", hide 3rd column)
[4]layout_column Property: Sets the component to display the specified column in 0 order. (android:layout_column="2", shown in the third column )
[5]layout_span Property: Sets the number of columns occupied by the component display in the No. 0 action order. (android:layout_span="3", Occupy 3 columns )
4. Absolutelayout (Absolute layout)
The position of the component can accurately specify its x/Y coordinate position on the screen. Although the coordinates can be precisely defined, but because the code is too rigid to write, so that in different devices, different resolutions of mobile devices can not be very good to display the results, so this layout is not recommended to use.
<?xml version= "1.0" encoding= "Utf-8"? ><absolutelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:orientation=" vertical " android:layout_width=" fill_parent " android:layout_height=" Fill_parent " > <button android:layout_width=" wrap_content " android:layout_height=" Fill_ Parent " android:text=" Button1 " android:layout_x=" 100DP " /> <button android:layout_ Width= "Fill_parent" android:layout_height= "wrap_content" android:text= "Button2" android:layout_ Y= "100DP" /> </AbsoluteLayout>
5. Framelayout (single frame layout)
It is said to be the simplest of the five layouts, because the single-frame layout places the component in the upper-left corner of the screen when a new component is defined, even if multiple components are defined in the layout, and the latter component always overwrites the previous component unless the last component is transparent.
<?xml version= "1.0" encoding= "Utf-8"? ><framelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " android:layout_width=" fill_parent " android:layout_height=" fill_parent " > < Button android:layout_width= "fill_parent" android:layout_height= "wrap_content" android:text= " Button1 " /> <button android:layout_width=" wrap_content " android:layout_height=" Fill_ Parent " android:text=" Button2 " /> <button android:layout_width=" Wrap_content " android:layout_height= "Wrap_content" android:text= "Button3" /> </FrameLayout>
Android Layout (ii)