zoukankan      html  css  js  c++  java
  • 绝对布局

          绝对布局由AbsoluteLayout代表。绝对布局就是Android不提供任何布局控制,而由开发人员自己通过X坐标、Y坐标来控制组件的位置。当使用AbsoluteLayout作为布局容器时,布局容器不再管理子组件的位置、大小——这些都需要开发人员自己控制。

          使用绝对布局时,每个子组件都可能指定如下两个XML属性。

    • layout_x:指定该子组件的X坐标。
    • layout_y:指定该子组件的Y坐标。

        实例:登录界面      

       下面介绍一个使用绝对布局开发的登录界面的实例,这个登录界面中所有组件都通过“绝对定位”的方式来指定位置。下面是该登录的界面布局文件。

      

    <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
      >
    <!-- 定义一个文本框,使用绝对位置 -->
    <TextView
        android:layout_x="20dip"
        android:layout_y="20dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户名:"/>
    <!-- 定义一个文本编辑框,使用绝对位置 -->
    <EditText 
        android:layout_x="80dip"
        android:layout_y="15dip"
        android:layout_width="wrap_content"
        android:width="200dp"
        android:layout_height="wrap_content"/>
    <!-- 定义一个文本框,使用绝对位置 -->
    <TextView
        android:layout_x="20dip"
        android:layout_y="80dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密   码:" />
    <!-- 定义一个文本编辑框,使用绝对位置 -->
    <EditText 
        android:layout_x="80dip"
        android:layout_y="75dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="200dp"
        android:password="true"/>
    <!-- 定义一个按钮,使用绝对位置 -->
       <Button 
           android:layout_x="130dip"
           android:layout_y="135dip"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:text="登   录"/>
    </AbsoluteLayout>

     运行该Activity将会出现图2.15所示的效果。

     

    图2.15绝对布局实例的登录界面

      

  • 相关阅读:
    MingW 综合资料参考
    技术文档编写的参考
    web地图的几个参考地址
    Linux的版本
    学习C语言一些的好的书和网站
    基于JAVA的web框架 GWT SmartGWT ExtGWT Vaadin
    Linux Shell的类别
    JavaScript图书推荐
    云盘分享 自绘画【儿童眼里的世界的确不同】
    GWT概述
  • 原文地址:https://www.cnblogs.com/wolipengbo/p/3341425.html
Copyright © 2011-2022 走看看