Introduction to Android: LinearLayout and AbsoluteLayout

Source: Internet
Author: User

The UI Layout of Android uses Layout as the container, and controls are arranged according to the rules above, which is similar to Swing and LWUIT in JAVA. Controls and Layout have many attributes that can be modified in Properties, similar to RAD such as. NET/Delphi. The most common attributes include the following:

Id = "@ + id/edtInput", which is a bridge between the UI and code

Gravity = "center", controls in Layout are centered
 

Layout_width = "fill_parent", automatically filled to the screen width. The same applies to layout_height.
 

Layout_width = "wrap_content", automatically filled into the control size, the same as layout_height
 

LinearLayout: The Layout used in the first article is LinearLayout. Its understanding is simple: the controls in LinearLayout are arranged horizontally or vertically:
Orientation = "horizontal": horizontal arrangement; orientation = "vertical": vertical arrangement
When LinearLayout is horizontal and the control in it uses layout_width = "fill_parent", the second group of controls will block the right side of the screen, that is, they will not be seen...

AbsoluteLayout is a layout defined by absolute coordinates. Because absolute coordinates are used to locate controls, AbsoluteLayout should be used less to implement adaptive interfaces. The controls in AbsoluteLayout use layout_x and layout_y to define their positions:
 

In TextView01, the X coordinate is 10px, And the Y coordinate is 10px:
View plaincopy to clipboardprint?
<AbsoluteLayout android: id = "@ + id/AbsoluteLayout01" android: layout_height = "wrap_content" android: layout_width = "fill_parent">
<TextView android: text = "TextView01" android: id = "@ + id/TextView01" android: layout_height = "wrap_content" android: layout_y = "10px" android: layout_width = "wrap_content" android: layout_x = "110px">
</TextView>
</AbsoluteLayout>

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.