2014-10-07 35 views
1

我正在一個應用程序中,我在全屏和頂部的操作欄中獲取地圖。在行動欄中,我還包括了導航抽屜。一切正常,但Button沒有顯示到MapView上。
如果我刪除了抽屜式導航功能,則會顯示按鈕。但我的要求就像我應該能夠顯示欄上的按鈕以及導航欄。
如何獲得谷歌地圖上的按鈕字段

的片段是:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.mobile.android.ui.MapActivity" 
    tools:ignore="MergeRootFrame" > 

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
<Button 
     android:id="@+id/button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="List" 
     android:layout_marginRight="20dip" 
     android:layout_marginTop="20dip" 
     android:layout_marginLeft="20dip" 
     android:layout_gravity="left|top" /> 
<fragment 
     android:id="@+id/map" 
     android:name="com.google.android.gms.maps.SupportMapFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 
<fragment android:id="@+id/navigation_drawer" 
     android:layout_width="@dimen/navigation_drawer_width" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:name="com.mobile.android.ui.NavigationDrawerFragment" /> 
</android.support.v4.widget.DrawerLayout> 
</FrameLayout> 
+0

你看到這個帖子? http://stackoverflow.com/questions/14694119/how-to-add-buttons-at-top-of-map-fragment-api-v2-layout – 2014-10-07 12:59:14

+0

是啊!我已經看到這篇文章..我得到的按鈕,如果我排除導航抽屜代碼!我的要求就像在我的屏幕上我希望導航抽屜和地圖上的按鈕......!@ Martin Pfeffer – anand 2014-10-07 13:01:38

+0

嗯,我無法想象它應該如何工作。你的意思真的是指NavigationDrawer而不是ViewPager?如果NavigationDrawer顯示在屏幕的左側/右側,則焦點會丟失。 – 2014-10-07 13:05:38

回答

1

我的項目支持類似的功能。但我用ViewPager

所以我的location_framgment.xml(見下面)能夠顯示地圖,我會通過ViewPager的默認行爲顯示它。 的XML文件看起來如下:

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

    <fragment 
     android:id="@+id/location_map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     class="com.google.android.gms.maps.MapFragment" /> 

</RelativeLayout> 

這裏我LocationFragment,延伸片段

+0

..感謝您的建議,我會嘗試這種方法..如果你能找到方法做導航抽屜..只是發佈你的答案 – anand 2014-10-07 13:48:10