Introduced
The application of various layouts in Android and the implementation of menu effects
Application of various layout methods, Framelayout, LinearLayout, Tablelayout, Absolutelayout, Relativelayout
Configures the context menu for the specified element, configures the options menu for the application, and implements the multilevel menu
1, various layout ways of the demonstration
Res/layout/main.xml
<?xml version= "1.0" encoding= "Utf-8"?>
<!--
Layout_width-wide. Fill_parent: Width follows the parent element; Wrap_content: Width follows the contents of itself; Specify a PX value to set the width
Layout_height-High. Fill_parent: The height follows the parent element to walk; Wrap_content: height follows itself; Specify a PX value to set the high
-->
<!--
LinearLayout-Linear layout.
Orientation-the arrangement of elements within the container. Vertical: The child elements are arranged vertically; horizontal: The child elements are arranged horizontally
Gravity-The arrangement of the contents. The most commonly used are top, bottom, left, right, center, etc., as detailed in the documentation
-->
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
android:orientation= "vertical" android:gravity= "right"
Android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" >
<!--
Framelayout-Cascade layout. With the upper left corner as the starting point, the elements within the framelayout are covered one layer at a level to show
-->
<framelayout android:layout_height= "Wrap_content"
Android:layout_width= "Fill_parent" >
<textview android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" android:text= "Framelayout" >
</TextView>
<textview android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" android:text= "Frame Layout" >
</TextView>
</FrameLayout>
<textview android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" android:text= "@string/hello"/>
<!--
Tablelayout-Tabular layout.
TableRow-rows within a table, each element in the row counts as a column
Collapsecolumns-Sets the column index of the column to be hidden in the TableRow within Tablelayout, separated by ","
Stretchcolumns-Sets the column index of the column in the Tablelayout within the TableRow that needs to be stretched (the column stretches to all available space), separated by ","
Shrinkcolumns-Sets the column index of the column in the TableRow in the tablelayout that needs to be shrunk (in order for the other columns to be squeezed out of the screen, the column automatically shrinks), separated by ","
-->
<tablelayout android:id= "@+id/tablelayout01"
Android:layout_width= "Fill_parent" android:layout_height= "Wrap_content"
android:collapsecolumns= "1" >
<tablerow android:id= "@+id/tablerow01" android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content" >
<textview android:layout_width= "Wrap_content"
android:layout_weight= "1" android:layout_height= "Wrap_content"
android:text= "Row 1 column 1"/>
<textview android:layout_width= "Wrap_content"
android:layout_weight= "1" android:layout_height= "Wrap_content"
android:text= "Row 1 column 2"/>
<textview android:layout_width= "Wrap_content"
android:layout_weight= "1" android:layout_height= "Wrap_content"
android:text= "Row 1 column 3"/>
</TableRow>
<tablerow android:id= "@+id/tablerow01" android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" >
<textview android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" android:text= "Row 2 column 1"/>
</TableRow>
</TableLayout>
<!--
Absolutelayout-absolutely positioned layout.
Layout_x-x coordinates. Vertex in upper-left corner
Layout_y-y coordinates. Vertex in upper-left corner
-->
<absolutelayout android:layout_height= "Wrap_content"
Android:layout_width= "Fill_parent" >
<textview android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" android:text= "Absolutelayout"
android:layout_x= "100px"
android:layout_y= "100px"/>
</AbsoluteLayout>
<!--
Relativelayout-relative positioning layout.
Layout_centerinparent-Position the current element horizontally and vertically in its container (similar properties are: Layout_centerhorizontal, layout_alignparentleft, etc.)
Layout_marginleft-Sets the distance of the current element relative to the left edge of its container
Layout_below-places the current element below the specified element
Layout_alignright-The current element is right-aligned with the specified element
-->
<relativelayout android:id= "@+id/relativelayout01"
Android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" >
<textview android:layout_width= "wrap_content" android:id= "@+id/abc"
android:layout_height= "Wrap_content" android:text= "Centerinparent=true"
Android:layout_centerinparent= "true"/>
<textview android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content" android:text= "marginleft=20px"
android:layout_marginleft= "20px"/>
<textview android:layout_width= "Wrap_content"
android:layout_height= "wrap_content" android:text= "xxx"
android:layout_below= "@id/abc" android:layout_alignright= "@id/abc"/>
</RelativeLayout>
</LinearLayout>