Android layout framelayout default is to put the layout of sub-view in the upper left corner, but can be set by the child view:
Android:layout_gravity
This parameter controls the layout position of the sub-view, implements the various sub-view layout positions of the framelayout, such as center left, center right, center, and so on, the key points in the android:layout_gravity parameter settings in combination with "center", "left", " Right "and so on, now give the XML code instance layout:
<framelayout 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 "> <Text View android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:background= "@an Droid:color/black "android:text=" upper left Corner "android:textcolor=" @android: Color/white "/> <textview Android:layout_width= "Wrap_content" android:layout_height= "wrap_content" android:layout_gravity= "Left|center "Android:background=" @android: Color/black "android:text=" left Center "android:textcolor=" @android: Color/whit E "/> <textview android:layout_width=" wrap_content "android:layout_height=" Wrap_content "and Roid:layout_gravity= "Right" android:background= "@android: Color/black" android:text= "Android:text Color= "@android: Color/white"/> <textviEW android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:layout_gravity= "R Ight|center "android:background=" @android: Color/black "android:text=" right Center "android:textcolor=" @android : Color/white "/> <textview android:layout_width=" wrap_content "android:layout_height=" Wrap_content " android:layout_gravity= "center" android:background= "@android: Color/black" android:text= "center" a Ndroid:textcolor= "@android: Color/white"/></framelayout>
Operation Result:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. Reprint Please specify source: Http://blog.csdn.net/zhangphil
Android framelayout Sub View Center (left center, right center), etc.