LinearLayout for Android layout Control

Source: Internet
Author: User

LinearLayout is a linear layout control. Its child controls are arranged horizontally or vertically, and all widgets or other containers are arranged according to their relative positions. When the boundary is exceeded, some controls will be missing or disappear. Therefore, each row in a vertical list only has one widget or iner, no matter how wide they are, A horizontal list will only have one row height (the height is the height of the top sub-control plus the border height ). LinearLayout maintains the interval and alignment between the widgets or containers it contains (right, center, or left ).

API description

Xml attributes

Android: baselineAligned: whether to allow users to adjust the baseline of its content.

Android: baselineAlignedChildIndex: When a linear layout is aligned with another layout, it specifies the baseline alignment of its content.

Android: gravity: Specifies how to place the content of this object (x/y coordinate value) in this object ).

Android: orientation: sets the direction of its content (horizontal/vertical ).

LinearLayout also supports specifying the filling weight for its widgets or container. The advantage is that the widgets or iner contained by the widget can fill the remaining space on the screen. This also avoids a bunch of widgets or containers in a large screen, but allows them to zoom in and fill the space. The remaining space is allocated to the screen based on the ratio of the widgets or containers values. The default weight value is 0, indicating that the value is displayed according to the actual size of widgets or containers. If the value is greater than 0, the remaining available space of the Container is split, the split size depends on the layout_weight of each widget or container and the ratio of the weight to all widgets or containers. For example, if there are three text boxes with two of the specified values being 1, the two text boxes will be scaled up proportionally and fill up the remaining space, the third text box is not enlarged and displayed in actual size. If the value of the first two text boxes is 2 and the value of one is 1, 2/3 of the remaining space after the third text box is displayed, and 1/3 of the remaining space is 1. That is, the greater the weight, the greater the importance.

If LinearLayout contains a sublinearlayout, the greater the weight between sublinearlayout, the smaller the importance. If LinearLayout A contains LinearLayout C, D, and C with A weight of 2 and D with A weight of 1, the 2/3 space on the screen is allocated to D with A weight of 1, 1/3 distribute to C with the weight of 2. In the case of nested LinearLayout, The sublinearlayout must be set with the permission value. Otherwise, the default situation is that the sublinearlayout without the permission value occupies the entire screen.

Related Article

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.