2012-05-04 48 views
1

我需要使用show first按鈕,而不僅僅是一張圖片。但我的應用程序無法啓動。首先「ImageView」,第二個「RelativeLayout」 - 工作,但首先「RelativeLayout」,第二個「ImageView」 - 不

這是作品:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 
    <ImageView 
    android:id="@+id/imageview" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    /> 

    <RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"> 
     <Button 
     android:id="@+id/make_photo_again" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/make_photo_again_label" 
     android:layout_alignParentLeft="true" 
     /> 
     <Button 
     android:id="@+id/edit_photo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/edit_photo_label" 
     android:layout_alignParentRight="true" 
     /> 
    </RelativeLayout> 

</LinearLayout> 

..但如果我把「圖片」下的「RelativeLayout的」應用程序無法正常工作。

真的不知道該怎麼做..

你能告訴我,爲什麼?

有什麼建議嗎?

+0

有你有你的圖像設置爲FILL_PARENT代替WRAP_CONTENT高度和寬度的原因是什麼? – ByteMe

+0

它爲什麼不起作用?只是說「它不起作用」並不意味着我們可能會遇到任何錯誤。 –

+0

你想要你的imageview在底部或頂部... –

回答

0

嘗試在XML驗證碼

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:weightSum="2"> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="0.3" > 

     <Button 
      android:id="@+id/make_photo_again" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:text="Save" 
      /> 

     <Button 
      android:id="@+id/edit_photo" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentRight="true" 
      android:text="Cancel" 
      /> 
    </RelativeLayout> 

    <ImageView 
     android:id="@+id/imageview" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1.7" 
     android:background="@drawable/edit_box_mytime" /> 

</LinearLayout> 
+0

謝謝!它運作良好!我忘了添加android:contentDescription =「」到。 – Evmorov

0

它應該工作,如果你把你的imageview在你的相對佈局剛開始的按鈕上方,然後imageview將在背面和按鈕將在imageview。

如果你把你在你的相對佈局結束ImageView的正下方兩個按鍵則imageview的將是在前面,它會隱藏按鈕.....

0

你的XML並沒有看錯。你得到了什麼錯誤。請描述。

相關問題