1. You can specify the filling weight for the linearlayout control. This allows its contained controls to fill the remaining space on the screen. This also avoids the congestion of all controls, but allows them to zoom in and fill in all spaces. The remaining space is allocated to the screen according to the weight ratio specified by these controls.
2. By default, the value of weight is 0, indicating that weight is displayed according to the actual size of the control. If weight is set to higher than zero.
3. The remaining space is allocated to the control based on the proportion of the Weight Value of the control to the weight of all controls. For example, there are two controls, one is 1 and the other is 2. the remaining space is allocated to control 1/(1 + 2) and control 2/(1 + 2. That is, the greater the weight, the greater the importance.
4. If linearlayout contains sub-linearlayout, the greater the weight between sub-linearlayout, 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.
<? XML version = "1.0" encoding = "UTF-8"?> <Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Orientation = "vertical"> <linearlayout xmlns: android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Orientation = "vertical" Android: layout_weight = "2"> <surfaceview Android: id = "@ + ID/surfaceview" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"/> </linearlayout> <linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android" Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: Orientation = "horizontal" Android: layout_weight = "1" Android: layout_gravity = "center"> <button Android: layout_width = "fill_parent" Android: layout_height = "wrap_content" Android: Id = "@ + ID/btntakepicture" Android: gravity = "center" Android: textsize = "20px" Android: TEXT = "photo"/> </linearlayout>