2013-10-11 30 views
12

我有简单的布局结构:的Android MapView的重叠DrawerLayout

DrawerLayout 
\-- FrameLayout // @+id/fragment_container 
\-- ListView // @+id/drawer_list 

点击我插入任何抽屉项目/经由FragmentTransaction.replace()与相应片段实例替换片段插入到R.id.fragment_container。其中一个碎片包含MapView

它在不同设备上呈现问题,但同时DDMS显示我正确的截图。

EDITED

问题出现在这种装置:

  • 华为U9508,机器人4.0.4(API 15)
  • HTC欲望A9191,机器人2.3.5( API 10)

no issue在此类设备上:

  • 三星Galaxy S2用的CyanogenMod 4.2.2的Android(API 17)
  • LG谷歌Nexus 4的Android 4.3(API 18)

可能有人帮助我了解并解决这个问题?

参见图片:

华为U9508,机器人4.0.4(API 15)

enter image description here enter image description here enter image description here

HTC欲望A9191,机器人2.3.5(API 10 )

enter image description here

DDMS

enter image description here

EDITED

活动布局:

<?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> 
+0

MapView的是贪婪 –

+0

你是什么意思?如何避免这一点? –

+0

Sry for OT,但你来自纽伦堡吗? –

回答

27

因此,我找到了解决方法:将MapView包装到容器中,并在上面放置空的View。多亏了这样的回答:https://stackoverflow.com/a/16231935/1891118

还有就是我更新的布局:

<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> 
+0

非常感谢,它也帮助我了类似的情况,但我使用VideoView而不是MapView。 –

+0

也适用于'ru.yandex.yandexmapkit.MapView'。简单而优雅的解决方案! – kit