Tenth lesson for Joshui teacher
One, LinearLayout
Linear layout, layout file set multiple LinearLayout to achieve the overall linear layout style.
Android:gravity= "Right" alignment, gravity is the meaning of the center of gravity
Common parameters: Center (center), Bottom (bottom), Top (top), right (starboard), left
Two, Android:layout_weight
Assigns a discretionary value to a control, without assigning a default of 0
A control with a weight of 0 gives him the layout in its original way; a control that has a weight assigned to it, which is laid out in the area other than the control with a weight of 0,
For example: There are 2 controls in the layout, one android:layout_weight= "2" and the other android:layout_weight= "1" The entire screen two-thirds is occupied by the first control, and the remaining One-third is occupied by the second control.
Example: To implement the layout:
<relativelayout 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 "Android:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" tools: Context= ". Mainactivity "><linearlayout android:theme=" @android: Style/theme.notitlebar.fullscreen "android:orientation = "vertical" android:layout_width= "match_parent" android:layout_height= "Match_parent" > <!--Horizontal Layout---& Lt LinearLayout android:orientation= "vertical" android:layout_width= "match_parent" android:layout_height = "Match_parent" android:layout_weight= "1" > <edittext android:layout_width= "match_parent" Android:layout_height= "Match_parent" andRoid:background= "#ff0000" android:layout_weight= "1" > </EditText> <edittext Android:layout_width= "Match_parent" android:layout_height= "Match_parent" android:layout_weight= "1 "android:background=" #00ff00 "> </EditText> <edittext Android:layout_width= "Match_parent" android:layout_height= "Match_parent" android:layout_weight= "1" android:background= "#0000ff" > </EditText> </LinearLayout> <!--vertical Layout--<linearlayout android:orientation= "Horizontal" android:layout_width= "mat Ch_parent "android:layout_height=" Match_parent "android:layout_weight=" 1 "android:layout_gravity=" rig HT "> <edittext android:layout_width=" match_parent "android:layout_height=" Match_parent " Android:layout_weight= "1" android:background= "#2F2F4F" > </EditText> <edittext and Roid:layout_width= "Match_parent" android:layout_height= "Match_parent" android:layout_weight= "1" a ndroid:background= "#B87333" > </EditText> </LinearLayout> </linearlayout ></RelativeLayout>
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Learning Notes (7) LinearLayout and Android:layout_weight Learning