2012-02-02 49 views
0

我想創建一個視圖,頂部有2個按鈕(1在屏幕左側和右側),手勢疊加在中間和底部的另一個按鈕屏幕右側。 這裏右上方按鈕沒有被放在右邊..請幫助.. 這裏是我的代碼安置按鈕在android中的權利

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#ffffff" 
    > 
<LinearLayout android:layout_height="wrap_content" 
android:layout_width="match_parent" 
android:id="@+id/linearLayout1"> 
    <ImageButton android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:background="@drawable/add" 
    android:id="@+id/bBlog"></ImageButton> 
    <ImageButton android:layout_height="wrap_content" 
android:layout_width="wrap_content" android:layout_gravity="right" android:background="@drawable/view" android:id="@+id/bBlog"></ImageButton> 
</LinearLayout> 

<RelativeLayout android:layout_height="fill_parent" android:layout_width="match_parent"> 

    <android.gesture.GestureOverlayView android:layout_alignParentRight="true" 
    android:id="@+id/myoverlay" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gestureColor="#000333"/> 
    <ImageButton android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/icon" 
    android:id="@+id/exit"></ImageButton> 
</RelativeLayout> 
</LinearLayout> 

回答

0

嘗試使用與layout_alignParentLeft和layout_alignParentRight一個RelativeLayout的這樣:

<RelativeLayout android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:id="@+id/linearLayout1"> 
     <ImageButton 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:src="@drawable/add" 
      android:layout_alignParentLeft="true" 
      android:id="@+id/bBlog"> 
     </ImageButton> 
     <ImageButton 
      android:layout_height="fill_parent" 
      android:layout_width="wrap_content" 
      android:src="@drawable/view" 
      android:layout_alignParentRight="true" 
      android:id="@+id/bBlog"> 
     </ImageButton> 

當然,您可以根據需要在其中添加填充。

+0

非常感謝你 – 2012-02-03 17:42:44

0

查看this的問題,爲什麼你無法設置右上角的圖像按鈕。爲了使它工作,請按照Nick給出的答案修改代碼。 :)