1. About Centering Components
①android:layout_gravity= the location of the "center" control in the parent control that contains the control. Similarly, when we set the android:layout_gravity= "left" property in the button control, it means that the button will be located at the right-hand side of the interface.
②android:scaletype= "Center"capture the middle of a picture③android:scaletype= "Centerinside"
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:orientation= "vertical" > <TextViewAndroid:id= "@+id/tv_title"Android:layout_width= "Match_parent"Android:layout_height= "0DP"Android:layout_weight= "1"Android:text= "Personal Center"android:gravity= "Center"android:textsize= "30px"Android:background= "#44cef6" /> <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "0DP"Android:layout_weight= "4"android:gravity= "Center" > <ImageViewAndroid:id= "@+id/img_me"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_gravity= "Center_vertical"android:src= "@drawable/ic_launcher" /> </LinearLayout> <LinearLayoutAndroid:layout_width= "Match_parent"Android:layout_height= "0DP"Android:layout_weight= "5" > <GridViewAndroid:id= "@+id/person_grid_view"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:numcolumns= "3"Android:stretchmode= "ColumnWidth"> </GridView> </LinearLayout></LinearLayout>
Android Interface (layout file layput)