Android development: Six layouts in interface design, androidlayouts

Source: Internet
Author: User

Android development: Six layouts in interface design, androidlayouts

1. Frame layout FrameLayout:

FrameLayout is the simplest layout object. All the display objects in it will be fixed in the upper left corner of the screen, and the position cannot be specified. The last one will directly overwrite the previous one.

2. Linear layout LinearLayout:

LinearLayout is one of the most common layout s and is also the parent class of the RadioGroup, TabWidget, TableLayout, TableRow, and ZoomControls classes, all the objects displayed in it are arranged vertically or horizontally (the arrangement is set by setting the Orentation attribute of LinearLayout)

3. Relative layout RelativeLayout:

RelativeLayout allows child elements to specify their positions relative to their parent or sibling elements, which is one of the most common layout methods in actual layout. It is flexible, has many attributes, is difficult to operate, and has a high possibility of conflict between attributes. When using relative layout, more tests are required.

Some important attributes used by RelativeLayout:
Class 1: the property value is true or false.
Android: layout_centerHrizontal --------------------------------- horizontal center
Android: layout_centerVertical ----------------------------------- vertical center
Android: layout_centerInparent ---------------------------------- completely centered over the parent Element
Android: layout_alignParentBottom ---------------------------- stick the bottom edge of the parent Element
Android: layout_alignParentLeft -------------------------------- stick the left edge of the parent Element
Android: layout_alignParentRight ------------------------------ tighten the right edge of the parent Element
Android: layout_alignParentTop -------------------------------- attach the upper edge of the parent Element
Android: layout_alignWithParentIfMissing ---------------------- reference the parent element if the corresponding sibling element cannot be found
Class 2: the property value must be the reference name "@ id/id-name" of the id"
Android: layout_below ------------------------------------------- below an element
Android: layout_abve ------------------------------------------ above an element
Android: layout_toLeftOf ---------------------------------------- on the left of an element
Android: layout_toRightOf --------------------------------------- on the right of an element
Android: layout_alignTop ---------------------------------------- the top edge of this element is aligned with the top edge of an element.
Android: layout_alignLeft ---------------------------------------- the left edge of this element is aligned with the left edge of an element.
Android: layout_alignBottom ---------------------------------- the bottom edge of this element is aligned with the bottom edge of an element.
Android: layout_alignRight --------------------------------------- the right edge of the current element is aligned with the right edge of an element.
Category 3: attribute values are specific pixel values, such as 30dip and 40px.
Android: layout_marginBottom -------------------------------- distance from the bottom edge of an element
Android: layout_marginLeft ------------------------------------ distance from the left edge of an element
Android: layout_marginRight ---------------------------------- distance from the right edge of an element
Android: layout_marginTop ------------------------------------ distance from the edge of an element

4. TableLayout:

TableLayout manages sub-elements in the form of columns. Each row is a TableRow layout object. Of course, it can also be a common View object. Each TableLayout element is a column, the total number of columns is determined by the row with the most columns.

Several important attributes of TableLayout:

CollapseColumns ----------------------------- set to hide the columns. The column IDs start from 0. Separate multiple columns with commas (,).
StretchColumns ------------------------------ set to automatically stretch those columns. The column IDs start from 0. Separate multiple columns ","
ShrinkColumns ------------------------------- set to automatically contract those columns. The column IDs start from 0. If multiple columns exist, use "," to separate them and use "*" to represent all columns, the same column can be set to both shrinkable and stretchable. 5. Absolute layout AbsoluteLayout:

Container manages the location and size of controls in a container. Developers specify the component location by specifying the X and Y coordinates.

Android: layout_x, which specifies the x coordinate value of the control in the container

Android: layout_y, which specifies the y coordinate value of the control in the container.

In practical applications, AbsoulteLayout is generally not applicable. Because the screen size of the APP's mobile phone is different, the resolution will certainly be different.

6. grid layout GirdLayout:

The GridLayout grid layout manager is added after android 4.0.

The grid layout manager divides the container into a grid with rows and columns. Each control is placed in a grid. You can also set related properties to make a control occupy multiple rows or columns.

For example, you can use a grid layout as a calculator.

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.