Android Learning--framelayout Frame layout

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.