2011-04-11 69 views
0

我想創建一個簡單的界面,頂部的MapView和底部的Button刷新說MapView。這兩個元素應該fill_parent寬度,但我希望他們不重疊在高度。我的問題是我的mapview似乎與我的Button重疊並隱藏它。這是我的layout.xml問題與佈局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" > 

    <com.google.android.maps.MapView 
      android:id="@+id/mapview" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent" 
      android:enabled="true" 
      android:clickable="true" 
      android:apiKey="my_api_key" /> 

    <Button 
      android:id="@+id/close" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_alignParentBottom="true" 
      android:text="@string/title_close" /> 
</LinearLayout> 

在此先感謝。

回答

1
  1. 使用RelativeLayout的
  2. 放置一個按鈕與layout_alignParentBottom="true"第一個孩子,使其layout_width="fill_parent"layout_height="wrap_content"
  3. 將MapView的第二位layout_above="@id/close"
  4. 讓它layout_width="fill_parent"layout_height="fill_parent"
+0

而使用'layout_height = 「WRAP_CONTENT」'上的按鈕,不要忘記 – 2011-04-11 10:41:32

+0

是的,謝謝。在上次編輯中已經有所改進。 – Olegas 2011-04-11 10:42:40

+0

很好,有幫助。你有沒有機會參考教程?除了developer.android.com中的一個 – Syllkons 2011-04-11 10:58:15

0

您必須使用layout_weight調整按鈕的大小和layout_height =「WRAP_CONTENT」

嘗試地圖重量= 0.5和按鍵更好地與2或東西映射 按鈕這樣