In LinearLayout, you can set weight for a sub-View. horizontal or vertical sub-views cannot overlay the entire screen. The remaining space is occupied by those views with weights. The default View weight is 0 (layout_weight = 0 ).
Using a basic wEight algorithm, the remaining space of LinearLayout has a View with "weight" allocated proportionally based on its weight.
In this example, the three sub-views of LinearLayout only have the weight android: layout_weight = "1" set for the second TextView. Therefore, this View occupies the entire middle part and the third TextView is squeezed to the bottom. If android: layout_weight = "1" is added to the other two textviews, the three textviews are evenly distributed on the screen:
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
Android: orientation = "vertical"
Android: background = "@ drawable/blue"
Android: layout_width = "match_parent"
Android: layout_height = "match_parent">
<! -View1 goes on top->
<TextView
Android: background = "@ drawable/box"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/linear_layout_3_top"/>
<! -View2 goes in the middle->
<TextView
Android: background = "@ drawable/box"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: layout_weight = "1 ″
Android: text = "@ string/linear_layout_3_middle"/>
<! -View3 goes on the bottom->
<TextView
Android: background = "@ drawable/box"
Android: layout_width = "match_parent"
Android: layout_height = "wrap_content"
Android: text = "@ string/linear_layout_3_bottom"/>
</LinearLayout>