Framelayout Tan Layout
Framelayout objects are like a piece of blank space that is pre-booked on the screen and can be filled in with elements. All elements are placed in the leftmost area of the Framelayout area, and cannot be assigned an exact position for these elements, and if there are multiple elements, the subsequent elements overlap on the previous element.
The following are examples of the XML layout and the Java code layout, respectively:
First, the layout of XML mode
1, first copy the a.jpg picture to the res/drawable-hdpi folder.
2. Create a blank activity
3. Open the "res/layout/activity_main.xml" file and modify it to the following code.
(1) Section ①
<?xml version= "1.0" encoding= "Utf-8"; each XML document starts with the XML prologue, and the first line in the preceding code is the XML preamble, <?xml version= "1.0" >. This line of code means parsing according to the 1.0 version of the XML rule. encoding = "Utf-8" indicates that the XML file is in UTF-8 encoded format. The encoding format can also be GB2312.
(2) Section ②
<linearlayout ... Represents the use of a single-frame layout manager.
(3) Section ③
Android:layout_width= "Match_parent" android:layout_height= "match_parent" means that the layout manager width and high charge will fill the entire screen width and height.
4. Drag 1 images from the toolbar to the activity ImageView, a button.
5. Open the "res/layout/activity_main.xml" file.
(1) Section ①
An image ImageView with ID imageView1 displays a picture.
(2) Section ②
A button with an ID of Button1 displays a button.
Because it is a single frame framelayout layout, the two controls are not able to make any layout and can only be placed in the upper-left corner as a benchmark.
6, the final display effect is as follows:
If the Framelayout single frame layout is just that, it can be said to be worthless!
The most important thing is that multiple layouts are nested, perhaps more meaningful, this in a later chapter we say, if you feel confused about Framelayout, you can first read: http://www.linuxidc.com/Linux/2011-12/49200p2.htm
Ii. layout of Java code mode
Now that we've learned to use XML for linearlayout layouts, let's learn how to do the same with Java code.
Temporary.
Android Learning--framelayout Frame layout