Android-06-布局管理器-绝对布局

本文介绍了Android开发中不推荐使用的AbsoluteLayout布局方式。通过X、Y坐标定位组件,导致应用难以在不同尺寸设备上适配。文章提供了AbsoluteLayout的基本语法及实例代码。

绝对布局AbsoluteLayout

AbsoluteLayout基本上都是不会使用,因为我们开发的应用需要在很多的机型上面进行适配,如果使用了这个绝对布局,可能你在4寸的手机上是显示正常的,而换成5寸的手机,就可能出现偏移和变形,所以这个布局不建议使用。AbsoluteLayout是直接通过X,Y坐标来控制组件在Activity中的位置的,Android中把屏幕的左上角坐标设定为(0,0),水平向左为宽度,垂直向下为高度。

1.基本语法格式

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" 
属性列表
>
</AbsoluteLayout >

2.实例

<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="32dp"

        android:layout_y="53dp"

        android:text="Button1" />

    <Button

        android:id="@+id/button2"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_x="146dp"

        android:layout_y="53dp"

        android:text="Button2" />

    <Button

        android:id="@+id/button3"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_x="85dp"

        android:layout_y="135dp"

        android:text="Button3" />

</AbsoluteLayout>

效果:::
在这里插入图片描述

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值