android - MapFragment 后面的 NavigationDrawer

标签 android google-maps navigation-drawer mapfragment

[已解决] 我将其添加到 MainActivity XML 文件中:

<FrameLayout
    android:id="@+id/place_map_here"
    android:layout_height="match_parent"
    android:layout_width="match_parent"/>
<FrameLayout
    android:id="@+id/bugfixview"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:background="@android:color/transparent"/>

以及我更改 fragment 的位置:

mapFragment = new FragmentMapView();
android.app.FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.add(R.id.place_map_here, mapFragment, "map");
ft.commit();

编辑:刚刚意识到我没有使用 MapFragment xml 文件。(较旧的版本很抱歉)

我将 Fragment 更改为 MapFragment,现在我的 NavigationDrawer 滑入了 MapFragment :( 代码:

MapFragmant xml(删除代码)

主要 Activity xml。这是我的抽屉声明

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >


<android.support.v4.widget.DrawerLayout         xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

<FrameLayout
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</FrameLayout>
<ListView
    android:id="@+id/drawer"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:background="#333"
    android:choiceMode="singleChoice"/>
</android.support.v4.widget.DrawerLayout>    
</RelativeLayout>

我希望这是您需要的信息,让您一如既往地出色并帮助像我这样的菜鸟:)

最佳答案

试试这个 hack 它可能对你有帮助,只需将你的布局更改为如下所示:

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

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" >

    <android.support.v4.widget.DrawerLayout
     android:id="@+id/drawer_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >


    <!-- hack to fix ugly black Background with maps v2 -->

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/transparent" />
</FrameLayout>

</LinearLayout>

关于android - MapFragment 后面的 NavigationDrawer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20948557/

相关文章:

android - 如何将 MarginBottom 添加到 BottomSheetDialogFragment?

android - 客户端未收到主题服务器端的 FCM 通知

android - 扩展 ActionBarActivity 的另一个 Activity 中的 Map Fragment 膨胀错误

javascript - 将信息框添加到 Google map 标记作为 HTML 标记属性 (AngularJS)

安卓移动控制

java - 如何在 Android 中使用 Base64 对字符串进行编码?

javascript - 如何在同一页面上创建多个谷歌地图(不是标记)?

android - 抽屉导航不工作

ios - 如何引用 MMDrawerController 左/右导航 Controller 中的实例方法?

flutter - 没有应用栏的抽屉 Flutter