android基础之AbsoluteLayout布局

发布时间:2020-06-08 08:30:18 作者:hagar
来源:网络 阅读:367

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布局


推荐阅读:
  1. android基础之ListView
  2. android基础之CheckBox

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

布局 andriod absolutelayout

上一篇:微信小程序源码解说:石头剪刀布(附源码下载)

下一篇:Kubernetes1.16基于Prometheus自定义指标弹性伸缩

相关阅读

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

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