2013-07-30 34 views
0

我正在使用圖像按鈕創建一個應用程序,麻煩的是圖形佈局顯示按鈕與在仿真器上運行時不同的位置。我已經在plz幫助下面發佈了我的代碼。我已經提供了一個圖形佈局的Dropbox鏈接與模擬器上顯示的內容。圖像按鈕是紅色的播放按鈕,在左邊的圖片上它出現在模擬器上的邊界之外,它完全放置在紅色播放按鈕上。注意:我將一個按鈕放在同一個按鈕的圖像上。這裏是鏈接:https://dl.dropboxusercontent.com/u/8104708/Comparison.png圖像按鈕出現在仿真器上的不同位置比圖形佈局

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    android:background="@drawable/title_screen" > 

    <ImageButton 
     android:id="@+id/ibPlay" 
     android:layout_width="400dp" 
     android:layout_height="400dp" 
     android:layout_marginLeft="100dp" 
     android:layout_marginTop="310dp" 
     android:background="@drawable/box_side_red" 
     android:onClick="@drawable/box_side_red_pressed_shadow" /> 

</LinearLayout> 
+2

後的你... – CRUSADER

+0

你可以張貼草圖你怎麼了你想要什麼,什麼截圖想要精確顯示imagebutton? –

+0

你在「不同的地方」下有什麼不足?將截圖放在這裏,說出它在手機上的外觀以及它在仿真器上的外觀。或至少創建一個結果的scetch。 – g00dy

回答

0

試試這個代碼可能是它工作正常

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/RelativeLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/mango" 
     android:orientation="vertical" > 

     <ImageButton 
      android:id="@+id/ibPlay" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:background="@drawable/apple" /> 

    </RelativeLayout> 
+0

感謝您的幫助,但在這種情況下,我相信在模擬器和圖形佈局中,按鈕都是在同一個位置創建的。當我嘗試將按鈕移動到我想要的位置時,出現了我的問題。也在xml中獲取layout_alignParentBotton/Right的後續警告,「Invalid Layout Param」 –

+0

您是否使用Relative Layout或LinearLayout? – Venky

+0

即使在使用相對佈局時,問題仍然存在:(。當將模擬器與圖形佈局進行比較時,它甚至會顯示按鈕的不同大小。 –