<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