Oleksii K.
Oleksii K.

Reputation: 5419

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:

There is no issue on such devices:

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>

Upvotes: 12

Views: 4609

Answers (1)

Oleksii K.
Oleksii K.

Reputation: 5419

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>

Upvotes: 31

Related Questions