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.