I'm trying to use RelativeLayout to display a map tile, surrounded by directional buttons, in a simple dialog.
I've tried a few variations, but inevitably, some of my buttons are missing.
In this version of the example, the up
and left
buttons are missing. If I declare the up
button first and place the tile
button relative to it, then up
shows. Do RelativeLayouts require the topmost widget to be declared first? Guess not, there would be no use for layout_above
then...
I can't post images (low rep), but you can view the result here.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/tile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5px"
android:layout_centerInParent="true"
android:src="@drawable/loading"
/>
<Button
android:id="@+id/up"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/tile"
android:layout_centerHorizontal="true"
android:drawableLeft="@drawable/up"
/>
<Button
android:id="@+id/left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@id/tile"
android:layout_centerVertical="true"
android:drawableLeft="@drawable/left"
/>
<Button
android:id="@+id/right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tile"
android:layout_centerVertical="true"
android:drawableLeft="@drawable/right"
/>
<Button
android:id="@+id/down"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tile"
android:layout_centerHorizontal="true"
android:drawableLeft="@drawable/down"
/>
<Button
android:id="@+id/in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tile"
android:layout_alignParentLeft="true"
android:text="@string/test_in"
/>
<Button
android:id="@+id/out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tile"
android:layout_alignParentRight="true"
android:text="@string/test_out"
/>
</RelativeLayout>