The key here is FrameLayout
. Children of a FrameLayout
stack on top of each other vertically.
Something like
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!-- The relative layout contains all of your buttons -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/button1"
android:text="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button2"
android:text="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button1"
/>
<Button
android:id="@+id/button3"
android:text="3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button1"
/>
<Button
android:id="@+id/button4"
android:text="4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button2"
android:layout_toRightOf="@id/button3"
/>
<Button
android:id="@+id/button5"
android:text="5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button3"
/>
<Button
android:id="@+id/button6"
android:text="6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button4"
android:layout_toRightOf="@id/button5"
/>
</RelativeLayout>
<!-- Your overlay -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:id="@+id/overlayText"
android:text="Overlay"
/>
</RelativeLayout>
</FrameLayout>
You might want to use a few nested LinearLayout
s (although try and avoid it) if you can't quite get the styling you want with a single RelativeLayout
to align your buttons.