2011-04-11 68 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或东西映射 按钮这样