温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

android基础之AbsoluteLayout布局

发布时间:2020-06-08 08:30:18 来源:网络 阅读:366 作者:hagar 栏目:移动开发

Absolute布局:

组件的位置可以准确的指定在屏幕的x/y坐标位置

虽然可以精确的去规定坐标,但是不建议使用。因为不同的设备  不同的分辨率的手机移动设备上不能很好的显示应有的效果

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    >

<Button

    android:layout_width="wrap_content"

    android:layout_height="fill_parent"

    android:text="Button1"

    />

<Button

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="button2"

    />

</AbsoluteLayout>

运行结果如下:

android基础之AbsoluteLayout布局

layout_x和layout_y属性:可以设置具体的x/y坐标

代码如下:

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    >

<Button

    android:layout_width="wrap_content"

    android:layout_height="fill_parent"

    android:text="Button1"

    android:layout_x="100dp"

    />

<Button

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="button2"

    android:layout_y="100dp"

    />

</AbsoluteLayout>

运行如下:

android基础之AbsoluteLayout布局


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI