tags:

views:

42

answers:

1

I've been stuck on this for a while so I thought I would ask. Previously I had an ImageView with buttons underneath. But I would like to have the buttons on top, and the ImageView underneath the buttons, but can't figure out how to do it. Here is the XML I have at the moment. Does anyone know what is wrong?

<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"&gt;

<RelativeLayout 
android:id="@+id/RelativeLayout01"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

         <Button
                                    android:id="@+id/Button_ILLNESS"
                                    android:layout_width="wrap_content"
                                    android:layout_height="@dimen/menu_button_height"
                                    android:layout_alignTop="@+id/Button_ILLNESS"

                                    android:textSize="@dimen/menu_button_text_size"
                                    android:text="@string/illness"></Button>
                    <Button
                                    android:id="@+id/Button_SYMPTOM"
                                    android:layout_width="wrap_content"
                                    android:layout_height="@dimen/menu_button_height"

                                    android:textSize="@dimen/menu_button_text_size"
                                    android:layout_toRightOf="@+id/Button_ILLNESS"
                                    android:text="@string/symptom"></Button>
                    <Button
                                    android:id="@+id/Button_REMEDY"
                                    android:layout_width="wrap_content"
                                    android:layout_height="@dimen/menu_button_height"

                                    android:textSize="@dimen/menu_button_text_size"
                                    android:layout_toRightOf="@+id/Button_SYMPTOM"
                                    android:text="@string/remedy"></Button>
                    <Button
                                    android:id="@+id/Button_HELP"
                                    android:layout_width="wrap_content"
                                    android:layout_height="@dimen/menu_button_height"

                                    android:textSize="@dimen/menu_button_text_size"
                                    android:layout_toRightOf="@+id/Button_REMEDY"
                                    android:text="@string/help"></Button>
                    <Button
                                    android:id="@+id/Button_INFO"
                                    android:layout_width="wrap_content"
                                    android:layout_height="@dimen/menu_button_height"

                                    android:textSize="@dimen/menu_button_text_size"
                                    android:layout_toRightOf="@+id/Button_HELP"
                                    android:text="@string/info"></Button>


</RelativeLayout>
<RelativeLayout
    android:id="@+id/RelativeLayout02"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent">
</RelativeLayout>
    <ImageView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ImageView_MenuHeader"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/splash_android_650x480"
    android:layout_alignParentBottom="true"></ImageView>

</LinearLayout>
+1  A: 

This would give you buttons on top:

<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"&gt;

<RelativeLayout android:id="@+id/RelativeLayout01"
    android:layout_width="fill_parent" android:layout_height="wrap_content">

    <Button android:id="@+id/Button_ILLNESS" android:layout_width="wrap_content"
        android:layout_alignTop="@+id/Button_ILLNESS" android:textSize="@dimen/menu_button_text_size"
        android:text="@string/illness" android:layout_height="50dip"></Button>
    <Button android:id="@+id/Button_SYMPTOM" android:layout_width="wrap_content"
        android:textSize="@dimen/menu_button_text_size"
        android:layout_toRightOf="@+id/Button_ILLNESS" android:text="@string/symptom" android:layout_height="50dip"></Button>
    <Button android:id="@+id/Button_REMEDY" android:layout_width="wrap_content"
        android:textSize="@dimen/menu_button_text_size"
        android:layout_toRightOf="@+id/Button_SYMPTOM" android:text="@string/remedy" android:layout_height="50dip"></Button>
    <Button android:id="@+id/Button_HELP" android:layout_width="wrap_content"
        android:textSize="@dimen/menu_button_text_size"
        android:layout_toRightOf="@+id/Button_REMEDY" android:text="@string/help" android:layout_height="50dip"></Button>
    <Button android:id="@+id/Button_INFO" android:layout_width="wrap_content"
        android:textSize="@dimen/menu_button_text_size"
        android:layout_toRightOf="@+id/Button_HELP" android:text="@string/info" android:layout_height="50dip"></Button>


</RelativeLayout>

<ImageView android:id="@+id/ImageView_MenuHeader" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:src="@drawable/icon"></ImageView>

</LinearLayout>

However, i would suggest using nested LinearLayout's, internal - horisontal for buttons and vertical for layout with buttons and image.

Asahi