Hi everyone
It has been a long time since the last blog post was published. At the end of the year, the project was very busy. First, I couldn't take the time to update it. Second, it may be a bit lazy. Whatever the reason, sorry, we will continue to update it later. Thank you for your support!
As usual, relax: A young man smoked smoke at the door of an office building. A woman passed by and said to him, "Do you know this thing will harm your health? I mean, have you noticed the warning on the cigarette holder )?"
The young man said, "It's okay, I'mProgramMember ".
The woman said, "What is this ?"
The programmer said, "We never care about warning, but about error"
Today, we mainly talk about the layout in Android. Some people will say that a search on the network isArticleIt's boring. Indeed, after all, so many people are writing and posting blog posts, but it seems that there are not many articles that will explain these layout knowledge points using an example. This blog post mainly explains some basic knowledge points, in the next article, we will use an example to summarize the layout knowledge. below is the target effect, which will be discussed in the next blog to facilitate future reading. Skip this step!
Android has five major la s:
Linear Layout-linear Layout
Relative Layout-relative Layout
Table Layout-table layout
Relative Layout-absolutelayout
Frame Layout-framelayout
I often use linear and relative la s during development. Here I will mainly explain these two la S.
Linear layout is mainly divided into vertical linear layout and horizontal linear layout.
Android: Orientation = "vertical" and Android: Orientation = "horizontal" have the following effects:
• Concept
• Allows child elements to specify their positions relative to other elements or parent elements (by ID ).
• If the layout file contains multiple layers of nested linearlayout, you can consider using the relative layout.
• Required attributes
• Android: layout_margintop = "25dip" // distance from the top
Android: gravity = "Left" // text position in the control
Android: layout_marginleft = "15dip // left margin
// Relative to the given ID Control
Android: layout_above: place the control at the bottom of the control on the control with the given ID (place the control on the control );
Android: layout_below: place the top of the control under the control with a given ID (place the control below the control );
Android: layout_toleftof align the right edge of the control with the left edge of the control with the given ID;
Android: layout_torightof align the left edge of the control with the right edge of the control with the given ID;
Android: layout_alignbaseline: Align the baseline of the control with the baseline of the given ID;
Android: layout_aligntop: Align the top edge of the control with the top edge of the given ID;
Android: layout_alignbottom: Align the bottom edge of the control with the bottom edge of the given ID;
Android: layout_alignleft: Align the left edge of the control with the left edge of the given ID;
Android: layout_alignright: Align the right edge of the control with the right edge of the given ID;
// Relative to the parent component
Android: layout_alignparenttop if it is true, align the top of the control with the top of its parent control;
Android: layout_alignparentbottom: If this parameter is set to true, the bottom of the control is aligned with the bottom of its parent control;
Android: layout_alignparentleft: if it is true, align the left of the control with the left of its parent control;
Android: layout_alignparentright: if it is set to true, align the right of the control with the right of its parent control;