Android absolute Layout

Source: Internet
Author: User

The absolute layout is represented by AbsoluteLayout. Absolute layout is like the empty layout in java AWT programming. Android does not provide any layout control, but developers control the component Position through X and Y coordinates. When AbsoluteLayout is used as the layout container, the layout container no longer manages the position and size of child components-all of which must be controlled by developers themselves. In the absolute layout, each component can specify the following two XML attributes: layout_x: Specify the X coordinate of the component layout_y: Specify the Y coordinate of the component. Example: main. xml code 01 on the logon interface <? Xml version = "1.0" encoding = "UTF-8"?> 02 <AbsoluteLayout xmlns: android = "http://schemas.android.com/apk/res/android" 03 android: orientation = "vertical" 04 android: layout_width = "fill_parent" 05 android: layout_height = "fill_parent" 06> 0708 <! -- Define a text box and use absolute positioning --> 09 <TextView10android: layout_x = "20dip" 11 android: layout_y = "20dip" 12 android: layout_width = "wrap_content" 13 android: layout_height = "wrap_content" 14 android: text = "username:"/> 15 <! -- Define a text editing box and use absolute positioning --> 16 <EditText17android: layout_x = "80dip" 18 android: layout_y = "15dip" 19 android: layout_width = "wrap_content" 20 android: layout_height = "wrap_content" 21 android: width = "200px"/> 22 <! -- Define a text box and use absolute positioning --> 23 <TextView24android: layout_x = "20dip" 25 android: layout_y = "80dip" 26 android: layout_width = "wrap_content" 27 android: layout_height = "wrap_content" 28 android: text = "Password:"/> 29 <! -- Define a text editing box and use absolute positioning --> 30 <EditText31android: layout_x = "80dip" 32 android: layout_y = "75dip" 33 android: layout_width = "wrap_content" 34 android: layout_height = "wrap_content" 35 android: width = "200px" 36 android: password = "true"/> 37 <! -- Define a button and use absolute positioning --> 38 <Button39android: layout_x = "130dip" 40 android: layout_y = "135dip" 41 android: layout_width = "wrap_content" 42 android: layout_height = "wrap_content" 43 android: text = "login"/> 44 </AbsoluteLayout> java code: view sourceprint? 01 package com. nuaa. absolutelayout; 0203 import android. app. activity; 04 import android. OS. bundle; 0506 public class AbsoluteLayoutTest extends Activity {07 public void onCreate (Bundle savedInstanceState) {08super. onCreate (savedInstanceState); 09 setContentView (R. layout. main); 10} 1112}

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.