Reprint: Android:layout_weight Detailed

Source: Internet
Author: User

Layout_weight is used to assign values to the importance of many views in a linear layout. All views have a layout_weight value, which defaults to zero, meaning how much screen space you need to show how large the view will occupy. If you assign a value above zero, the free space in the parent view is split, and the split size depends on the layout_weight value of each view and the overall layout_weight value of the value in the current screen layout and the layout_ of the other view screen layout The percentage of the weight value. For example, let's say we have a text label and two text editing elements in the horizontal direction. The text label does not specify a layout_weight value, so it will occupy the minimum space needed to provide it. If the layout_weight value of each of the two text-editing elements is set to 1, the two are split equally between the remaining widths of the parent view layout (since we declare the two to be of equal importance). If the layout_weight value of the first of the two text-editing elements is set to 1, and the second is set to 2, then two-thirds of the remaining space is given to the first, and One-third to the second (the smaller the value, the higher the importance). See Example 1. 2. 7. 12. 19. 26. 33. 40. 41.

Reprint: Android:layout_weight Detailed

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.