2011-05-30 100 views
1

我有以下的android佈局,顯示在左側和右側的屏幕一個腳趾列表視圖。在屏幕右邊的按鈕中添加一個按鈕

<?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="horizontal"> 
<ListView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_weight="1" android:id="@+id/ListView01"/> 
<ListView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="3" android:id="@+id/ListView02"/> 

現在我想添加一個按鈕顯示在屏幕的右下方。 任何人都可以幫我解釋我該怎麼做?

+0

你是指在列表的右下方還是右邊? – 2011-05-30 12:30:06

+0

是的,這是錯誤的,我的意思是屏幕的右下方 – George32x 2011-05-30 12:34:18

回答

1

可能的解決方案應該是:添加一個RelativeLayout作爲根佈局,並將該按鈕放在LinearLayout之後,屬性爲layout_below和layout_right(LinearLayout作爲參考)。

2

先去除線性佈局,使用相對layout.for按鈕使用下面的命令

機器人:layout_alignParentBottom = 「真」機器人:layout_alignParentRight = 「真

0

嘗試使用下面的代碼

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="horizontal" 
    android:background="#ffffff" 
    > 
    <Button 
    android:id="@+id/click" 
    android:layout_width="100dip" 
    android:layout_height="60dip" 
    android:text="Click" 
    android:layout_alignParentRight="true" 
    /> 

    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 

     android:id="@+id/ListView02" 
     android:background="#00ff00" 
     android:layout_toLeftOf="@+id/click" 
     /> 
    <ListView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/ListView01" 
     android:background="#000000" 
     android:layout_alignParentLeft="true" 
     android:layout_toLeftOf="@+id/ListView02" 
     /> 


</RelativeLayout> 

感謝 迪帕克

+0

其實我希望我的按鈕從listaview2下來 – George32x 2011-05-30 13:23:17