2013-10-11 44 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