Android Layoutweight FAQ

Source: Internet
Author: User

<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" match_parent "android:layout_height=" Match_parent "Tools:context = "${relativepackage}.${activityclass}" android:orientation= "horizontal" ><!--doubts: The first case: the width of the control is set to Wrap_content, The ratio is assigned to 1:2:3, and the interface display is the second case that is displayed according to the assigned proportions: The control width is set to match_parent, the scale is assigned to 1:2:2, the interface is displayed as 2:1:1 in the third case: the control width is set to match_parent and the scale is assigned to 1 : 2:3, the interface is displayed as 2:1 because Layout_weight calculates the proportion of the remaining space after the width of the control is allocated, weight defaults to 0 for the formula: Remaining space = parent control width-all control width and occupied parent control space = control width + Percentage of remaining space * The rest of the space takes the first control example: When set to Wrap_content, the remaining space = the parent control width-3 * 0, the occupied parent control Space =0+1/6 * The parent control width =1/6* The parent control width, the remaining two controls are similar when set to Match_parent, the remaining space = Parent control width -3* Parent control width =-2 the parent control space = parent control width +1/5* ( -2* parent control width) =3/5 parent control width, similar to the remaining two when the 1/5 ratio becomes 1:2:3, the occupied space of the first control = parent control width +1/6* ( -2* Parent control width =2/3 the width of the parent control, the second is 1/3 the width of the parent control, and the third is 0, so the third control is not visible-<button android:layout_width= "Match_parent" an  droid:layout_height= "Wrap_content" android:layout_weight= "1"/> <button       Android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_weight= "2"        /> <button android:layout_width= "match_parent" android:layout_height= "Wrap_content" android:layout_weight= "3"/></linearlayout>

  

Android Layoutweight FAQ

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.