. NET programmers quickly learn how Android development-layout and click events are written

Source: Internet
Author: User

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

    1. 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

Related Article

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.