如何获得谷歌地图上的按钮字段

问题描述:

我正在一个应用程序中,我在全屏和顶部的操作栏中获取地图。在行动栏中,我还包括了导航抽屉。一切正常,但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://*.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

我的项目支持类似的功能。但我用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