Android學習第四天之AbsoluteLayout絕對佈局

佈局篇之AbsoluteLayout絕對佈局

一  功能:

(1.1)用屏幕上的像素來定義控件的位置,一般來說是用子元素的最左上角來指代整個子元素的位置,(0,0)是指起始位置在屏幕的左上角,當子元素下移或者右移時,子元素的x或者y座標也相應的增大

(1.2)缺陷:現在很少使用AbsoluteLayout絕對佈局,因爲實際應用中各種手機的屏幕分辨率並不一樣,在一個設備上調試好了的空間的距離,往往很難在別的種類的手機上使用

二  AbsoluteLayout子類控件的屬性:

      android:layout_x="84dp"   控制當前子類控件的x位置

      android:layout_y="54dp"   控制當前子類控件的y位置

三 練習:由於此佈局不怎麼使用,所以稍作了解即可


<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="84dp"
        android:layout_y="54dp"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="29dp"
        android:layout_y="142dp"
        android:text="Button" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="156dp"
        android:layout_y="146dp"
        android:text="Button" />

</AbsoluteLayout>



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