Android five big layouts

Source: Internet
Author: User

1.LinearLayout Linear layout:
Common Properties:
How the sub-class controls are arranged: android:orientation= "vertical"/"horizontal" vertical or horizontal
Location of the subclass control in the layout: android:gravity= "center"
Center: Horizontal vertical center; center_vertical vertical Center; center_horizontal Horizontal Center;
Right: The subclass control is at the left....bottom of the current layout; such as

2.RelativeLayout Relative layout:
The relative position of the control or the way the subclass control is relative to the position of the parent class container.
Common Properties:
Android:layout_alignparentleft= "true" sub-class control relative to the current parent class container on the left
Android:layout_alignparenttop= "true" sub-class control relative to the current parent class container on top
Android:layout_marginleft= "41DP" subclass control distance from the left side of the parent class container
Android:layout_margintop= "33DP" subclass control distance from top of parent class container
Android:layout_centerinparent= "true" sub-class controls are both horizontally and vertically centered relative to the parent class container
Android:layout_centerhorizontal= "trandroid:layout_below=" @+id/button1 "The control is at the bottom of the given ID control
Android:layout_torightof= "@+id/button1" The control is on the right side of the given ID control
Android:layout_above= "@+id/button1" The control is above the given ID control
Android:layout_toleftof= "@+id/button1" The control is on the left side of the given ID control
Android:layout_alignbaseline= "@+id/button1" The contents of the control are on a line with the contents of the given ID control

Android:layout_alignbottom the bottom edge of the control is aligned with the bottom edge of the given ID control
Android:layout_alignleft the left edge of the control is aligned with the left edge of the given ID control
Android:layout_alignright the right edge of the control is aligned with the right edge of the given ID control
Android:layout_aligntop the top edge of the control aligns with the top edge of the given ID control the UE "sub-class control is centered horizontally relative to the parent class container
Android:layout_centervertical= "true" sub-class controls are centered vertically relative to the parent class container

Android:layout_below= "@+id/button1" The control is at the bottom of the given ID control
Android:layout_torightof= "@+id/button1" The control is on the right side of the given ID control
Android:layout_above= "@+id/button1" The control is above the given ID control
Android:layout_toleftof= "@+id/button1" The control is on the left side of the given ID control
Android:layout_alignbaseline= "@+id/button1" The contents of the control are on a line with the contents of the given ID control

Android:layout_alignbottom the bottom edge of the control is aligned with the bottom edge of the given ID control
Android:layout_alignleft the left edge of the control is aligned with the left edge of the given ID control
Android:layout_alignright the right edge of the control is aligned with the right edge of the given ID control
Android:layout_aligntop the top edge of the control aligns with the top edge of the given ID control

3.FrameLayout Frame layout:
The components added by Framelayout cannot be placed in place, and the latter component overwrites the previous component. The effect that you can use to implement color gradients, such as setting the size of each component gradually decreasing.
Android:foreground is to set the foreground map, in front of all child views
Android:keepscreenon is to keep the screen awake
Android:foregroundgravity is the location where the foreground map is set

4.AbsoluteLayout Absolute Layout:
Also called the coordinate layout control, you can direct the absolute position of the child element (x, y)
not used, mobile phone screen size difference is relatively large, there are screen adaptation defects.
Common Properties:
android:layout_x;
android:layout_y;

5.TableLayout Table layout:
Manages child controls in the form of rows and columns, each of which behaves as a TableRow object.
Properties of the layout:
android:collapsecolumns= "Up"//hide a column separated by commas
android:shrinkcolumns= "Up"//shrinks a column (stretched, makes content in the screen)
android:stretchcolumns= "Up"//Stretch a column, fill in extra blanks, replace all columns with *
Common control Properties:
android:layout_column= "1" The control is displayed in the second column
Android:layout_span = "2" The control occupies a column width, merging columns

Android five big layouts

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.