Android MapView overlaps DrawerLayout

只谈情不闲聊 提交于 2019-11-27 13:58:05

问题


I have simple layout structure:

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

By clicking of any drawer item I'm inserting/replacing fragment via FragmentTransaction.replace() into R.id.fragment_container with corresponding Fragment instance. One of those Fragments contains MapView.

And it has rendering problems on different devices, but at the same time DDMS shows me right screenshot.

EDITED

Issue appears on such devices:

  • Huawei U9508, Android 4.0.4 (API 15)
  • HTC Desire A9191, Android 2.3.5 (API 10)

There is no issue on such devices:

  • Samsung Galaxy S2 with CyanogenMod Android 4.2.2 (API 17)
  • LG Google Nexus 4 Android 4.3 (API 18)

Could anybody help me to understand and fix this problem?

See images:

Huawei U9508, Android 4.0.4 (API 15)

HTC Desire A9191, Android 2.3.5 (API 10)

DDMS

EDITED

activity layout:

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

fragment layout:

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

回答1:


So, I find workaround solution: just wrap MapView into container and place empty View above. Thanks to this answer: https://stackoverflow.com/a/16231935/1891118

There is my updated layout:

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


来源:https://stackoverflow.com/questions/19314383/android-mapview-overlaps-drawerlayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!