First, understand a few properties:
1. Layout
1) android:orientation= "vertical" vertical layout
2) android:orientation= "Horizontal" horizontal layout
2. High and wide layout of control content
1) android:layout_width= "Match_parent", covered with the entire screen. [Match parent window]
2) android:layout_height= "Wrap_content", layout elements will change size based on content. [Content includes]
3. Layout scale
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.
Second, the following two examples of implementation:
1) three buttons horizontally placed
<linearlayout android:layout_width= "match_parent" android:layout_height= "Wrap_content" Android:ori entation= "Horizontal" > <button android:layout_width= "match_parent" Android:layout_heig ht= "Wrap_content" android:layout_weight= "1" android:text= "MC"/> <button and Roid:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "m+"/> <button android:layout_width= "Match_parent" Android:layout_ height= "Wrap_content" android:layout_weight= "1" android:text= "M"/> <button Android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "Mr"/> </LinearLayout>
Borrow Layout_weight to make the three buttons occupy the same proportion of the display.
Second, two-level button: The first layer three, the second 2
<linearlayout android:layout_width= "match_parent" android:layout_height= "Wrap_content" Android:ori entation= "vertical" > <linearlayout android:layout_width= "match_parent" Android : layout_height= "Wrap_content" android:layout_weight= "3" android:orientation= "Horizontal" > <button android:layout_width= "match_parent" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "1"/> <button android:l Ayout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "2"/> <button android:layout_width= "Match_parent" android:layout_height= "Wrap_content" android:layout_weight= "1" android:text= "3"/> </LinearLayout> <linearlayout android:layout_width= "match_parent" android:layout_height= "Wrap_ Content "android:layout_weight=" 3 "android:orientation=" Horizontal "> <button android:layout_width= "0px" android:layout_height= "wrap_content" android:layout_weight= "2" android:text= "0"/> <button android:layout_width= "0px" android:layout_height= "wrap_content" android:layout_weight= "1" android: text= "."/> </LinearLayout> </LinearLayout>
Use a large layer first, set the weight scale is 3. The weight of the first button in the second layer is 2/3 of that of the layer.
Android Linear layout LinearLayout (vii)