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>



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