Basic Android tutorial -- 2.2.6 AbsoluteLayout (absolute layout) and android absolute Layout

Source: Internet
Author: User

Basic Android tutorial -- 2.2.6 AbsoluteLayout (absolute layout) and android absolute Layout
Basic Android tutorial -- 2.2.6 AbsoluteLayout (absolute layout)

Tags (separated by spaces): basic Android tutorial

This section introduces:

As mentioned above, the five la s in Android are described in this section. The sixth layout is AbsoluteLayout (absolute layout ),
The reason for putting this at the end is that we will not use the absolute layout. Of course, you can skip this one directly.
As a programmer who prefers growth, we can still understand the AbsoluteLayout layout,
I believe most people who have learned Java know that we have used this absolute layout in Java swing (not spring), but Android
This is because the application we developed needs to be adapted to many models. If you
If this absolute layout is used, it may be normal for you to display it on a 4-inch mobile phone. If you change it to a 5-inch mobile phone, an offset may occur.
And deformation. Therefore, this is not recommended. Of course, if you don't want to write code and want to play android, write
During layout, you can drag the required components to the interface through the ADT! This AbsoluteLayout is directly obtained through the X and Y coordinates.
Controls the position of a component in the Activity! In addition, the Unit is dp!

1. Four control attributes (unit: dp ):

① Control size:
Android: layout_width:Component widthAndroid: layout_height:Component height
② Control position:
Android: layout_x:Set X coordinates of a componentAndroid: layout_y:Set Y coordinates of components

2. Example:

A simple logon interface is a drag-and-drop interface directly on the ADT, so the code will not be pasted:

① First set it to AbsoluteLayout absolute layout:

2. Drag two textviews, EditText, and a button on the left to the interface, and drag it to the interface. It looks nice.

Drag and Drop, And the last drop is the problem. It is estimated that it is an ADT problem. Next you can:
① Modify the coordinates of the Code to see what looks nice
② Of course, you can also set coordinates directly on the right side:

After modification:

Of course, you may not like the above two methods. If you want to drag it, You can directly generate the correct code ~!
OK. No problem. We recommend that you use the previous interface prototype to introduce the tool DroidDraw.

Summary

Okay. We have already finished introducing the six la s in Android. We recommend that you use the weight attribute of LinearLayout +
RelativeLayout to build our interface ~ Well, here we are. Thank you ~

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.