android基礎之AbsoluteLayout佈局

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>

運行結果如下:

wKiom1OmRNKwwexkAAD_ieNO_JA148.jpg

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>

運行如下:

wKioL1OmRMzhM60YAAEiAWZoLBo621.jpg


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章