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绝对布局实例的登录界面

      

  • 相关阅读:
    sql语句左链接left join--3张表关联
    combobox下拉框
    sql in()批量操作
    spring事务传播特性实验(2):PROPAGATION_REQUIRED实验结果与分析
    【kubernetes】kubectl logs connection refused
    k8s1.4.3安装实践记录(3)下载基础镜像
    k8s1.4.3安装实践记录(2)-k8s安装
    k8s1.4.3安装实践记录(1)-etcd、docker、flannel安装配置
    python爬虫常用数据整理函数
    django-xadmin常用内容记录
  • 原文地址:https://www.cnblogs.com/wolipengbo/p/3341425.html
Copyright © 2011-2022 走看看