Android MapView与抽屉布局重叠
我有简单的布局结构:Android MapView与抽屉布局重叠,android,google-maps,android-mapview,drawerlayout,Android,Google Maps,Android Mapview,Drawerlayout,我有简单的布局结构: DrawerLayout \-- FrameLayout // @+id/fragment_container \-- ListView // @+id/drawer_list 通过单击任何抽屉项目,我将通过FragmentTransaction.replace()将片段插入/替换到带有相应片段实例的R.id.fragment\u容器中。其中一个片段包含MapView 它在不同的设备上有渲染问题,但同时DDMS给我显示了正确的屏幕截图 已编辑 问题出现在此类设备上:
DrawerLayout
\-- FrameLayout // @+id/fragment_container
\-- ListView // @+id/drawer_list
通过单击任何抽屉项目,我将通过FragmentTransaction.replace()
将片段插入/替换到带有相应片段实例的R.id.fragment\u容器中。其中一个片段包含MapView
它在不同的设备上有渲染问题,但同时DDMS给我显示了正确的屏幕截图
已编辑
问题出现在此类设备上:
- 华为U9508,安卓4.0.4(API 15)
- HTC Desire A9191,安卓2.3.5(API 10)
此类设备上没有问题
:
- 三星Galaxy S2搭载CyanogenMod安卓4.2.2(API 17)
- LG谷歌Nexus 4Android 4.3(API 18)
<?xml version="1.0" encoding="utf-8"?>
<DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<!-- The main content view -->
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<!-- The navigation drawer -->
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:orientation="vertical"
/>
</DrawerLayout>
片段布局:
<?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="wrap_content"
>
<!-- other views here -->
<com.google.android.gms.maps.MapView
android:id="@+id/consumer_profile_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
因此,我找到了解决方案:只需将
MapView
包装到容器中,并将空的视图
放在上面。多亏了这个答案:
这是我更新的布局:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
你是什么意思?如何避免这种情况?Sry代表OT,但您是纽伦堡人吗?您能展示一下您的XML布局吗?非常感谢,它也帮助了我处理类似的情况,但我使用的是视频视图而不是地图视图。也适用于ru.yandex.yandexmapkit.MapView
。一个简单而优雅的解决方案!还修复了com.mapbox.mapboxsdk.maps.MapView的相同问题。谢谢