溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

android基礎之AbsoluteLayout布局

發(fā)布時間:2020-06-08 08:30:18 來源:網(wǎng)絡 閱讀:372 作者:hagar 欄目:移動開發(fā)

Absolute布局:

組件的位置可以準確的指定在屏幕的x/y坐標位置

雖然可以精確的去規(guī)定坐標,但是不建議使用。因為不同的設備  不同的分辨率的手機移動設備上不能很好的顯示應有的效果

<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問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI