Absolute Layout
An Absolute Layout lets you specify exact
locations (x/y coordinates) of its children. You specify the exact x and y coordinates on the screen for each control.This is
not recommended for most UI development (in fact AbsoluteLayout is currently deprecated) since absolutely positioning every element on the screen makes an inflexible UI that is much more difficult to maintain.
AbsoluteLayout Attributes
Following are the important attributes specific to AbsoluteLayout :
| Attribute |
Description |
| android:id |
This is the ID which uniquely identifies the layout. |
| android:layout_x |
This specifies the x-coordinate of the view. |
| android:layout_y |
This specifies the y-coordinate of the view. |
Example 1 :
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="OK"
android:layout_x="50px"
android:layout_y="361px" />
<Button
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_x="225px"
android:layout_y="361px" />
</AbsoluteLayout>