AbsoluteLayout
The AbsoluteLayout lets you specify the exact location of its children. Consider the following UI defined in
main.xml
:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:layout_width="188px"
android:layout_height="wrap_content"
android:text="Button"
android:layout_x="126px"
android:layout_y="361px"
/>
<Button
android:layout_width="113px"
android:layout_height="wrap_content"
android:text="Button"
android:layout_x="12px"
android:layout_y="361px"
/>
</AbsoluteLayout>
Figure 6 shows the two
Button
views located at their specified positions using the
android_layout_x
and
android_layout_y
attributes.
Figure 6 Views laid out using AbsoluteLayout
Author's Note. You should ideally use
AbsoluteLayout
when you need to reposition your views when there is a change in the screen rotation.