android - 在ImageView上方的按钮?

问题描述:

我一直坚持这一段时间,所以我想我会问。以前我有一个ImageView和下面的按钮。但我想要在顶部的按钮和按钮下的ImageView,但无法弄清楚如何去做。这里是我目前使用的XML。有谁知道什么是错的?android - 在ImageView上方的按钮?

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

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

     <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:text="@string/illness" 
      android:textSize="@dimen/menu_button_text_size" > 
     </Button> 

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

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

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

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

    <RelativeLayout 
     android:id="@+id/RelativeLayout02" 
     android:layout_width="fill_parent" 
     android:layout_height="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:layout_alignParentBottom="true" 
     android:src="@drawable/splash_android_650x480" > 
    </ImageView> 

</LinearLayout> 
+1

那么如何将LinearLayout背景设置为这个特定的可绘制图像呢? – bhups 2010-08-26 20:17:13

+0

@bhuos - 甜蜜,那就是诀窍。谢谢!你应该把你的建议作为答案,以便我可以选择它作为正确的答案。 – 2010-08-26 20:38:35

这将使你的按钮在上面:

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

    <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_height="50dip" 
      android:layout_alignTop="@+id/Button_ILLNESS" 
      android:text="@string/illness" 
      android:textSize="@dimen/menu_button_text_size" > 
     </Button> 

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

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

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

     <Button 
      android:id="@+id/Button_INFO" 
      android:layout_width="wrap_content" 
      android:layout_height="50dip" 
      android:layout_toRightOf="@+id/Button_HELP" 
      android:text="@string/info" 
      android:textSize="@dimen/menu_button_text_size" > 
     </Button> 
    </RelativeLayout> 

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

</LinearLayout> 

不过,我会建议使用嵌套LinearLayout的,内部 - horisontal按钮和垂直的按钮和图像布局。

+0

用于缩进和格式化的用户'CTRL + SHIFT + F'或'CTRL + I' – 2014-02-10 11:43:37