[android] Android Layout 之 AbsoluteLayout 学习
绝对定位AbsoluteLayout,又可以叫做坐标布局,可以直接指定子元素的绝对位置,这种布局简单直接,直观性强,但是由于手机屏幕尺寸差别比较大,使用绝对定位的适应性会比较差。
在绝对定位中,如果子元素不设置layout_x和layout_y,那么它们的默认值是0,也就是说它会像在FrameLayout一样这个元素会出现在左上角。
<?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" > <VideoView android:id="@+id/videoView1" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_x="2dp" android:layout_y="106dp" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="141dp" android:layout_y="4dp" android:text="Button2" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button1" /> <EditText android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="52dp" android:layout_y="52dp" android:ems="10" android:hint="绝对布局" android:inputType="datetime" /> </AbsoluteLayout>

AbsoluteLayout 在2.3以后,不推荐使用。据说在游戏开发中使用的比较多。

浙公网安备 33010602011771号