Android学习第四天之AbsoluteLayout绝对布局

布局篇之AbsoluteLayout绝对布局

一  功能:

(1.1)用屏幕上的像素来定义控件的位置,一般来说是用子元素的最左上角来指代整个子元素的位置,(0,0)是指起始位置在屏幕的左上角,当子元素下移或者右移时,子元素的x或者y坐标也相应的增大

(1.2)缺陷:现在很少使用AbsoluteLayout绝对布局,因为实际应用中各种手机的屏幕分辨率并不一样,在一个设备上调试好了的空间的距离,往往很难在别的种类的手机上使用

二  AbsoluteLayout子类控件的属性:

      android:layout_x="84dp"   控制当前子类控件的x位置

      android:layout_y="54dp"   控制当前子类控件的y位置

三 练习:由于此布局不怎么使用,所以稍作了解即可


<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="84dp"
        android:layout_y="54dp"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="29dp"
        android:layout_y="142dp"
        android:text="Button" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="156dp"
        android:layout_y="146dp"
        android:text="Button" />

</AbsoluteLayout>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值