Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
813 views
in Technique[技术] by (71.8m points)

google maps - Android MapView overlaps DrawerLayout

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)

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

HTC Desire A9191, Android 2.3.5 (API 10)

enter image description here

DDMS

enter image description here

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...