[Android] (Learn note 2) drill down into XML layout properties

Source: Internet
Author: User

1 Layout Parameters

Some property names start with "Layout_", such as Android:layout_marginleft, while other property names are not.

A property whose name does not start with "layout_" acts on the component. When a component is generated, a method is called to configure itself according to the property and property values;

A property whose name begins with "Layout_" acts on the parent component of the component. These properties are also called layout parameters. They are responsible for informing the parent component of how to schedule its own subcomponents internally. That is, as long as the layout parameter is included, it has its own parent component.

2 inner and outer margins

Inner margin: android:padding

Outer margin: android:layout_marginxxx

As described in the 1th, the margin is to tell the parent component how much of an edge is spaced when the subassembly is laid out. The meaning of the padding is that when plotting itself, it is much less than what is contained.

3 Add the corresponding horizontal mode for the default generated layout

When the screen rotates, the default generated layout rotates accordingly, but the part of the component is mechanically stretched and re-adjusted itself and its own subcomponents. How to adjust the layout of the horizontal mode effectively according to your needs? To achieve this, you can try the following steps:

    1. To create the Res/layout-land directory, copy the layout files from the Res/layout directory to the Res/layout-land directory;
    2. By changing the layout file under the Res/layout-land directory, the goal of self-modifying horizontal layout is achieved.

4 How the Android:layout_weight property works

This property tells the LinearLayout (parent component) How the subassembly is arranged. When determining the display width of the subassembly view, LinearLayout uses the mixed values of layout_weight and layout_width. The main points are completed in two steps:

    1. LinearLayout View Layout_width property values (view Layout_height property values vertically). Suppose you currently have a horizontal linearlayout that contains two subcomponents: a button and a checkbox, and they display different lengths of text information, and they cannot fill the entire linearlayout in the case of their respective wrap_content. After the arrangement, there is additional space (extra spaces).
    2. LinearLayout Check the Layout_weight property value. Depending on the value of the Layout_weight attribute, the LinearLayout allocates additional space to each sub-component as a proportion.

[Android] (Learn note 2) drill down into XML layout properties

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.