绝对布局由AbsoluteLayout代表。绝对布局就像java AWT编程中的空布局,就是Android不提供任何布局控制而是由开发人员自己通过X坐标、Y坐标来控制组件的位置。当使用AbsoluteLayout作为布局容器时,布局容器不再管理子组件的位置、大小---这些都需要开发人员自己控制。
使用绝对布局是,每个组件都可指定如下两个XML属性
 
layout_x:指定该组件的X坐标
 
layout_y:指定该组件的Y坐标
 
例子:登录界面
 
main.xml代码
 
01<?xml version="1.0" encoding="utf-8"?>
02<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
03android:orientation="vertical"
04android:layout_width="fill_parent"
05android:layout_height="fill_parent"
06>
07
08<!-- 定义一个文本框,使用绝对定位 -->
09<TextView
10android:layout_x="20dip"
11android:layout_y="20dip"
12android:layout_width="wrap_content"
13android:layout_height="wrap_content"
14android:text="用户名:"/>
15<!-- 定义一个文本编辑框,使用绝对定位 -->
16<EditText
17android:layout_x="80dip"
18android:layout_y="15dip"
19android:layout_width="wrap_content"
20android:layout_height="wrap_content"
21android:width="200px"/>
22<!-- 定义一个文本框,使用绝对定位 -->
23<TextView
24android:layout_x="20dip"
25android:layout_y="80dip"
26android:layout_width="wrap_content"
27android:layout_height="wrap_content"
28android:text="密码:"/>
29<!-- 定义一个文本编辑框,使用绝对定位 -->
30<EditText
31android:layout_x="80dip"
32android:layout_y="75dip"
33android:layout_width="wrap_content"
34android:layout_height="wrap_content"
35android:width="200px"
36android:password="true"/>
37<!-- 定义一个按钮,使用绝对定位 -->
38<Button
39android:layout_x="130dip"
40android:layout_y="135dip"
41android:layout_width="wrap_content"
42android:layout_height="wrap_content"
43android:text="登录"/>
44</AbsoluteLayout>
java 代码:
 
view sourceprint?
01package com.nuaa.absolutelayout;
02
03import android.app.Activity;
04import android.os.Bundle;
05
06public class AbsoluteLayoutTest extends Activity {
07public void onCreate(Bundle savedInstanceState){
08super.onCreate(savedInstanceState);
09setContentView(R.layout.main);
10}
11
12}

android绝对布局的更多相关文章

  1. 【腾讯Bugly干货分享】Android动态布局入门及NinePatchChunk解密

    本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57c7ff5d53bbcffd68c64411 作者:黄进——QQ音乐团队 摆脱 ...

  2. Xamarin.Android之布局文件智能提示问题

    一.前言 看到有人问关于xamarin.android的布局没智能提示问题(VS 2015),当然,写布局这东西没提示这是一件相对痛苦的事 ,所以这里就提供一个解决的方案! 二.解决方案 想要智能提示 ...

  3. android—-线性布局

    android五大布局之线性布局. 1.线性布局的特点:各个子元素彼此连接,中间不留空白 而今天我们要讲解的就是第一个布局,LinearLayout(线性布局),我们屏幕适配的使用 用的比较多的就是L ...

  4. Android基本布局

    android基本布局有三种:LinearLayout,RelativeLayout,FrameLayout. 一.LinearLayout 1,这是一种垂直布局(或者水平布局),可以通过下面这一句来 ...

  5. android layout布局属性

    参考:http://blog.csdn.net/msmile_my/article/details/9018775 第一类:属性值 true或者 false           android:lay ...

  6. Android 学习第10课,Android的布局

    Android的布局 线性布局

  7. Android 优化布局层次结构

    前面介绍过使用HierarchyViewer和Android lint来优化我们的程序,这一篇算是总结性的,借助一个小例子来说用怎么优化应用布局.这个例子是android官网给出的,作者也当一把翻译. ...

  8. Android 五大布局

    Android 五大布局:  FrameLayout(框架布局),LinearLayout (线性布局),AbsoluteLayout(绝对布局),RelativeLayout(相对布局),Table ...

  9. Android界面布局基本知识简述

    Android手机操作系统在模拟器中进行相关的编写,可以帮助我们实现各种功能需求.尤其是在界面的操作方面显得更为突出.在这里我们就可以对Android界面布局的相关操作来对这方面的知识进行一个深入的了 ...

  10. android的布局管理器

    理论上通过setContentView(view)能够把一个view设置到activity中,但当你有很多个view控件的时候,就需要用android的布局管理器来管理view控件了. android ...

随机推荐

  1. ROS知识(1)----ROS Jade安装

    ROS入门难,进去之后会是很简单,这是很多人的经验.但是今天安装ROS就吃了闭门羹,安装成功后,回顾发现,关键是操作系统Ubantu14.04没有安装好,一些系统包没有及时更新导致的.这里总结下ROS ...

  2. MySQL之分页问题解决

    最近遇到很多大分页的问题,服务器负载很高,SQL的执行时间也较长,非常的头痛.下面我们就说说分页问题的解决. 大家都知道对于mysql来说,select * from table where x=‘? ...

  3. 测试用例设计——WEB通用测试用例(转)

    http://qa.blog.163.com/blog/static/190147002201111332029404/

  4. CentOS下的RPM包制作教程收集(rpmbuild)

    http://www.jinbuguo.com/redhat/rpmbuild.html(中文手册) https://www.linuxidc.com/Linux/2016-09/134955.htm ...

  5. keystone 命令简要说明

    catalog: keystone catalog 可以显示所有已有的service keystone catalog --service service-type 显示某个service信息 end ...

  6. STM32F10X FLASH and SRAM size

    STM32F10X FLASH Size SRAM Size Device Type --------------------------------------------------------- ...

  7. Struts2的ActionError&ActionMessage示例

    本教程显示使用Struts2的 ActionError 和 ActionMessage 类. 1. ActionError – 是用来发送错误信息反馈给用户 - 通过 <s:actionerro ...

  8. SpringMVC杂记(1) 使用阿里巴巴的fastjson

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  9. GoF设计模式三作者15年后再谈模式

    Erich Gamma, Richard Helm, 和 Ralph Johnson在GoF设计模式发表15年以后,再谈模式,另外一位作者,也是四色原型的发明者Peter已经过世. 提问者:如今有85 ...

  10. combogrid 摘要

    可装载组合框 - ComboBox 继承自$.fn.combo.defaults,通过$.fn.combobox.defaults覆盖默认值 combobox显示的是一个可以编辑的文本框和一个下拉列表 ...