# #常见的布局
* LinearLayout Linear layout
Linear layout to the left and right pull is not moving,
> Orientation vertical|horizontal for linear layouts
> Weights for linear layouts weight and 0dip use
<?XML version= "1.0" encoding= "Utf-8"?><!--Linear layout controls top-down neat arrangement -<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" >vertical Arrangement, the contents of which are arranged vertically<ButtonAndroid:layout_width= "Match_parent"Android:layout_height= "0dip"height is 0, the height is proportional to the weight, android:layout_weight= "1"The weight is 1, then the height is the weight and 1 parts namely 1/3, the weight can only follow the width or height of 0, Android:text= "Button 1" /> <ButtonAndroid:layout_width= "Match_parent"Android:layout_height= "0dip"Android:layout_weight= "1"Android:text= "button 2" /> <ButtonAndroid:layout_width= "Match_parent"Android:layout_height= "0dip"Android:layout_weight= "1"Android:text= "button 3" /></LinearLayout>
<?XML version= "1.0" encoding= "Utf-8"?><!--linear layout controls neatly arranged from left to right -<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "Horizontal" >The horizontal arrangement, without the weight, will be squeezed out,<ButtonAndroid:layout_width= "0dip"width is 0, android:layout_height= "Wrap_content"height fills the parent form, as wide as the parent component width, android:layout_weight= "2"The weight is 2, then the width is the weight and the 2 parts namely 2/4, the weight can only follow the width or height of 0, Android:text= "Button 1" /> <ButtonAndroid:layout_width= "0dip"Android:layout_height= "Wrap_content"Android:layout_weight= "1"The weight is 1, then the width is the weight and 1 copies of the Android:text= "button 2" /> <ButtonAndroid:layout_width= "0dip"Android:layout_height= "Wrap_content"Android:layout_weight= "1"The weight is 1, then the width is the weight and 1 copies of the Android:text= "button 3" /></LinearLayout>
The above code:
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical" >the outermost layer is a linear layout, arranged vertically<LinearLayoutandroid:orientation= "Horizontal"the inside is arranged horizontally android:layout_width= "Match_parent"width is the parent form width android:layout_weight= "1"weight of 1 android:layout_height= "0dip" >Write 0, you can use weights.<TextViewAndroid:layout_width= "0dip"width of 0 android:layout_height= "Fill_parent"height is parent form android:layout_weight= "1"width weight of 1 android:background= "#ff0000" /> <TextViewAndroid:layout_width= "0dip"Android:layout_height= "Fill_parent"Android:layout_weight= "1"Android:background= "#00ff00" /> <TextViewAndroid:layout_width= "0dip"Android:layout_height= "Fill_parent"Android:layout_weight= "1"Android:background= "#0000ff" /> </LinearLayout> <LinearLayoutandroid:orientation= "vertical"inside the vertical arrangement android:layout_width= "Match_parent"Android:layout_weight= "1"Android:layout_height= "0dip" > <TextViewAndroid:layout_width= "Fill_parent"width is parent form android:layout_height= "0dip"height of 0 android:layout_weight= "1"Height weight of 1 android:background= "#ff0000" /> <TextViewAndroid:layout_width= "Fill_parent"Android:layout_height= "0dip"Android:layout_weight= "1"Android:background= "#00ff00" /> <TextViewAndroid:layout_width= "Fill_parent"Android:layout_height= "0dip"Android:layout_weight= "1"Android:background= "#0000ff" /> </LinearLayout></LinearLayout>
Android LinearLayout Linear layout