<linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android : orientation= "Horizontal" > <imageview android:layout_width= "Wrap_content" android: layout_height= "Wrap_content" android:src= "@drawable/ic_launcher" /> <textview android: text= "mobile phone anti-theft" android:layout_width= "wrap_content" android:layout_height= "wrap_content"/> </ Linearlayout>
<LinearLayout>
<linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android: Layout_gravity= "Center_horizontal" <!---------------------> android:orientation= "Horizontal" > <imageview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:src= "@drawable/ic_launcher" /> <textview android:text= "mobile phone anti-theft" Android: Layout_width= "Wrap_content" android:layout_height= "wrap_content"/> </LinearLayout>
<LinearLayout>
android:layout_gravity= "Center_horizontal" layout represents the relative parent control, the child control changes, and the gravity represents the content _center_horizontal
<LinearLayout>
<linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android: Layout_gravity= "Center_horizontal" android:gravity= "center_vertical" android:orientation= "Horizontal" > <imageview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:src= "@drawable/ic_launcher" /> <textview android:text= "mobile phone anti-theft" Android: Layout_width= "Wrap_content" android:layout_height= "wrap_content"/> </LinearLayout>
<LinearLayout>
Android:gravity= "center_vertical" Gravity relative to the content center_vertical, 1) If there is content on the button, then the content center_vertical
2) If there is a control under LinearLayout, then the control under LinearLayout center_vertical
<linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android: Layout_gravity= "Center_horizontal" android:gravity= "center_vertical" android:layout_margin= "50DP " android:orientation= "Horizontal" > <imageview android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:src= "@drawable/ic_launcher" /> <textview android:text= "mobile phone anti-theft" android:layout_width= "wrap_content" android:layout_height= "wrap_content"/ > </LinearLayout>
<LinearLayout>
android:layout_margin= "50DP" layout: Represents the relative parent control, and the child control changes. Margin: Represents the margin.
Layout_margin represents the margin with the parent control
<linearlayout android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android: Layout_gravity= "Center_horizontal" android:gravity= "center_vertical" android:layout_margin= "50DP " android:orientation= "Horizontal" android:padding= "70DP" > <imageview android:layout_ Width= "Wrap_content" android:layout_height= "wrap_content" android:src= "@drawable/ic_launcher" / > <textview android:text= "mobile phone anti-theft" android:layout_width= "wrap_content" android:layout_ height= "Wrap_content"/> </LinearLayout>
<LinearLayout>
Android:padding= "70DP" indicates content padding
The difference between Android layout_gravity, Gravity, Layout_margin, padding