2013-12-16 54 views
0

我想要設計帶Google地圖和頁腳的屏幕。使用頁腳,我將它與不同的xml佈局文件分開,並使用'包括'標籤。問題是覆蓋地圖的頁腳。下面描述了我的xml佈局文件。帶有頁腳的Android地圖片段

map_viewer.xml

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

     <FrameLayout 
      android:id="@+id/layout_mapview" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_above="@id/actionBtn" 
      android:layout_marginTop="5dp"> 

      <fragment 
        xmlns:map="http://schemas.android.com/apk/res-auto" 
        android:id="@+id/map" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        map:uiRotateGestures="false"    
        class="com.glympsefunctionalitydemo.maps.Map"/> 
      <RelativeLayout 
        android:id="@+id/footer_map" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"> 
        <include layout="@layout/footer/>" 
      </RelativeLayout> 
</RelativeLayout> 

footer.xml

<merge xmlns:android="http://schemas.android.com/apk/res/android"> 
    <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:background="@null"> 

      <ImageButton 
        android:id="@+id/actionBtn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:layout_alignParentBottom="true" 
       android:background="@null" 
       android:src="@drawable/btn_actions"/> 
      <ImageButton 
        android:id="@+id/mapBtn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="@dimen/footer_horizontal_margin" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentBottom="true" 
       android:background="@null" 
       android:src="@drawable/btn_map"/> 
      <ImageButton 
        android:id="@+id/mapBtn" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginRight="@dimen/footer_horizontal_margin" 
       android:layout_alignParentRight="true" 
       android:layout_alignParentBottom="true" 
       android:background="@null" 
       android:src="@drawable/btn_settings"/> 
    </RelativeLayout> 
</merge> 

地圖通吃的空間,頁腳疊加的地圖。但我只想讓地圖在顯示頁腳時留下空間。我如何得到它的工作。

enter image description here

+0

顯示你的代碼。 – keshav

+0

對不起,keshav,我貼的代碼。謝謝! – pqtuan86

+0

你爲什麼使用FrameLayout?有必要嗎 ? – keshav

回答

1

嘗試此map_viewer.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <fragment 
     xmlns:map="http://schemas.android.com/apk/res-auto" 
     android:id="@+id/map" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     class="com.glympsefunctionalitydemo.maps.Map" 
     map:uiRotateGestures="false" /> 

    <include 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     layout="@layout/footer" > 
    </include> 

</LinearLayout> 
+0

感謝您的快速回復!但它仍然不起作用,地圖片段在真實設備上運行時填充了所有父屏幕高度。 – pqtuan86

+0

但這裏很好。嘗試將include佈局代碼放入map_viewer.xml中 – keshav

+0

是的,當我們將腳註代碼放入map_viewer.xml時,它可以正常工作!但是當使用標籤時問題就出現了,也許系統在渲染時不知道包含的佈局。 – pqtuan86