2011-04-28 28 views
0

我在構建一個包含兩個按鈕和一個MapView的佈局。這些按鈕應放置在MapView的上方和下方。我已經嘗試了幾種佈局組合(相對,線性,框架...),但MapView不支持layout_height = wrap_content,除非我使用像layout_height =「200dp」這樣的特定高度。MapView不支持layout_height = wrap_content

顯示tope按鈕,但最下面的按鈕不是。以下是我的測試XML文件。

有什麼建議嗎?

的android:layout_width = 「FILL_PARENT」 機器人:layout_height = 「FILL_PARENT」 >

<Button  
    android:id="@+id/btn1" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button1" 
    android:background="#FF0000" /> 

<com.google.android.maps.MapView 
    android:id="@+id/map1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:apiKey="my map key (removed for example)" 
/>   

<Button  
    android:id="@+id/btn2" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button2" 
    android:background="#00FF00" />  

回答

0

我是一個全新的機器上,並沒有什麼測試這有可能,但這可能工作:

<RelativeLayout 
android:layout_width="fill_parent"   
android:layout_height="fill_parent"> 
<Button  
    android:id="@+id/btn1" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button1" 
    android:background="#FF0000" /> 

<Button  
    android:id="@+id/btn2" 
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content" 
    android:text="Button2" 
    android:background="#00FF00" />  

<com.google.android.maps.MapView 
    android:id="@+id/map1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:apiKey="my map key (removed for example)" 
    android:layout_below="@id/btn1" 
    android:layout_above="@id/btn2" 
/></RelativeLayout> 
+0

謝謝,Mapview仍然不能很好地與其他佈局玩,但是這樣做。 – RickR 2011-06-10 00:15:09

1

我有同樣的問題(我的地圖視圖下注兩個佈局而不是按鈕),並用「height = 0dp」和「weight = 1」來解決它,所以mapview可以調整到上面和下面的佈局。

<com.google.android.maps.MapView 
    android:id="@+id/map1" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:apiKey="my map key (removed for example)" 
/>