Focus on today's headlines-do the full stack siege Lion, learn the code to read, love the whole stack, more love life. Provide programmer technical and life guidance dry goods.
This series of courses is dedicated to veteran programmers who can quickly get started with Android development. System-wide from one. NET Programmer's perspective to summarize Android development in one step.
Previous lesson: All-Stack engineers must: Android mobile phone development, lesson six
Main content:
Layout
Click events
Layout
When it comes to the development of the Android front page, you have to say the Android layout. That is, where the control should be placed.
1.1 Relative layout
When we create a new layout file, the default is relative layout. Relative layouts are relative to non-relative layouts. As the name implies, a relative layout is a layout relative to the position of some controls. All controls are positioned relative to each other.
In the relative layout, it can be easily used. Controls that are added by default in relative layouts are stacked by default in the upper-left corner:
Centered relative to the parent control:
Set the position relative to a control:
1.2 Linear layout (this type of layout is generally used)
Linear layouts are arranged horizontally or vertically in linear order. All controls are placed in turn. For example, we can change the default relative layout to a linear layout:
We can set whether the Orientation property is horizontal or vertical.
By default, they are arranged horizontally.
The effect of horizontal arrangement of three columns is achieved by linear layout.
1.3 Table layout
Click events
First: OnClick Property
Front page:
Background processing:
Second way: Anonymous class
The Third Kind: inner class
The fourth kind: When the button is too much, let the activity implement the Onclicklistener interface, through the ID to determine how to operate.
If you feel the article can also, please click Subscribe to follow me.
Write code also to read, love the whole stack, more love life
Do the full stack siege lion
Can add groups to Exchange Learning: QQ Group number: 538742639
. NET programmers quickly learn how Android development-layout and click events are written