The Android layout is divided into five types: linear layout, relative layout, table layout, frame layout, grid layout
1) framelayout (frame layout)
Frame layout is the simplest layout object, which is customized to a blank alternate area on the user's screen, after which the user can populate a single object, such as a picture. All child elements will be fixed in the upper left corner of the screen; we cannot specify a location for a child element in Framelayout. And the new sub-elements will directly overwrite the old child elements, similar to a stack structure, of course, it is not necessarily all blocked, so look at the transparency and size to determine.
<framelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" android:foreground= "#ff0000" > <textview android:layout_width= "wrap_ Content "android:layout_height=" wrap_content "android:text=" @string/loginname "android:textsize=" @dimen/dp50 "/ > <textview android:layout_width= "wrap_content" android:layout_height= "wrap_content" android:text= "@string/ LoginName "android:textsize=" @dimen/dp100 "/> </FrameLayout>
Remember some features:
1) All the components will be placed in the upper left corner of the area;
2) The size of the frame layout is determined by the largest child control in the sub-control,
3) If all components are the same size, you can only see the topmost component at the same time! The reason is to overwrite
4) foreground= "#ff0000" foreground color, specified colors or pictures will always cover the other
5) foregroundgravity= "fill_vertical" foreground color of the position, this property specifically I did not understand
2) GridLayout (Grid layout)
Grid layout is a new layout after Android4.0, he and Tablelayout and linearlayout in the operation of a little resemblance, of course, he naturally has his extraordinary, mainly in the linearlayout based on new attributes, more easy to use. In use, note that if a component is not marked across rows, the component is in order by default only one cell.
<gridlayout xmlns:android= "http:// Schemas.android.com/apk/res/android " xmlns:tools=" Http://schemas.android.com/tools " android:id=" @+id /gridlayout1 " android:layout_width=" wrap_content " android:layout_height=" Wrap_content " android: Rowcount= "3" android:columncount= "2" android:orientation= "Horizontal" > <Button android:id= "@+id/btn" android:layout_columnspan= "2" //across 2 columns android:layout_gravity= the "Fill" //button fills two columns of white space because there is no need to set the layout_width layout_height android:text= "0"/> ----------- ----- <gridlayout>
Remember some features:
1) Android:orientation: How to arrange the components
2) Android:layout_gravity: component Alignment
3) Android:rowcount: Set the number of lines
4) Android:columncount: Set Number of columns
There are also new properties for the components inside the container:
1) Android:layout_rowspan: number of rows occupied
2) Android:layout_columnspan: Number of occupied columns
3) android:layout_gravity = "Fill" component fills the entire row or column that is traversed, which is necessary for components that have cross-row or cross-columns.
About the grid layout, in fact, I am also very headache, because the beginning of learning without relevant experience, always can not compile through, after looking at this blog, so on the study up. This blog is especially important when Gridpanel is running in Eclipse.
The following content is reproduced from the blog:
http://blog.csdn.net/jianghuiquan/article/details/8299973
Problems you may encounter:
When the reader sets the layout to GridLayout, there will be an inexplicable error,
If the code syntax is not wrong, it could be a problem with the configuration file androidmanifest.xml
Because GridLayout was launched after Android 4.0, the API level is 14
Only need to change the MINSDK in the configuration file to 14 or later , save, the problem is solved!
Please refer to:
http://blog.csdn.net/jianghuiquan/article/details/8299973
Android Eighth lesson--ui Layout 2