Android development ------ linear layout of user interfaces

Source: Internet
Author: User

A good application is inseparable from a user-friendly user interface. Before learning other things. We should first learn how to compile the program layout (appearance)

Today, we will learn about the android UI Layout-LinearLayout.

LinearLayout: Linear layout. We can know from the name that its elements are linear.

Note: in some future code writing, we use hard encoding to write string values,

The string value will not be defined in the strings. xml file. At this time, eclipse IDE will receive a yellow underline warning, so we can ignore it.

Key knowledge points:

  

                                                                                                       

Check the running effect.

    

Next, let's explain the structure and principle of the Code.

We have compiled a LinearLayout layout. It should be noted that the LinearLayout label must be a root element, and no elements can appear outside it. But any layout element can be nested in it. That is, the layout of the outermost layer cannot have sibling elements (same-level elements)

Therefore, the following situations cannot occur:

                       

 

Now I know what linear layout is.

One of them is arranged behind the other, just like a line.

New tags:

<EditText/>: text box used to receive user input.

<Button/>: click the Button to process the event when you click it.

Set element attributes:

We will mainly talk about the following attributes of the pipeline. You can study the other attributes by yourself.

= "Fill_parent" 

    

Android: layout_height

Android: orientation

= "Center"

    

= "@ + Id/idName"

   

 

So how is the effect in the second text box realized?

It is very simple. In this way, we see black spots rather than letters and numbers.

 

In the above Code, the value is. Now we can change it to see what the situation is.

 

View Code

 

  

No error. The elements are arranged horizontally now. Let's add several more elements.

                                           

Running effect:

    

 

Why?

In horizontal arrangement, if the length of an element exceeds the activity length, the element overflows and some elements cannot be displayed.

 

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.