欢迎光临成都祈钰瑶科技有限公司网站!祝您生活愉快!
热线电话: 18982081108
✕

成都服务器托管,成都GPU服务器租用,成都高防BGP宽带租用,成都机柜租用托管

android基础之AbsoluteLayout布局

Absolute布局:

我们拥有10余年网页设计和网站建设经验,从网站策划到网站制作,我们的网页设计师为您提供的解决方案。为企业提供成都网站建设、成都做网站、微信开发、微信小程序开发、手机网站制作设计、H5网站设计、等业务。无论您有什么样的网站设计或者设计方案要求,我们都将富于创造性的提供专业设计服务并满足您的需求。

组件的位置可以准确的指定在屏幕的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布局