【发布时间】:2014-01-16 20:05:25
【问题描述】:
[已解决] 我将此添加到 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"/>
以及我更改片段的位置:
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(已删除代码)
MainActivity 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>
我希望这是您需要的信息,让您像往常一样出色并帮助像我这样的菜鸟:)
【问题讨论】:
-
如果您更改布局以使根为
DrawerLayout而不是RelativeLayout,会发生什么? -
你能发布java代码吗,我想看看你是如何替换片段的。
-
你能把
MapView放在main里面吗?
标签: android google-maps navigation-drawer mapfragment