oscar
oscar

Reputation: 647

Android MapView half-screen white error

I have a strange problem using a MapView in Android.

It works fine until i click on a overlay item and then back. The map is as you can see in the screenshot, half white, and continues to be so until i zoom in and out and everything is back to normal.

Have anyone else seen this before? Could it be due to something in my layout?

EDIT
I have found that this problem is related to that I have a MapView in the Activity that i start. Somehow the MapView height seems to be cached when I come back. Tried invalidating and reloading mapview, but nothing works. Someone must have seen this error before?


MapView error

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.google.android.maps.MapView
        android:id="@+id/MapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:apiKey="xxx"
        android:clickable="true"
        android:enabled="true"
         />

    <include
        android:id="@+id/Progress"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        layout="@layout/progress"
        android:visibility="gone" />

</RelativeLayout>

Upvotes: 2

Views: 457

Answers (1)

oscar
oscar

Reputation: 647

The problem was somehow related to the MapView reusing something about the layout when switching between activities.

Solved by doing the following in onResume:

LayoutParams layoutParams = mMapView.getLayoutParams();
mMapView.setLayoutParams(layoutParams);

Upvotes: 3

Related Questions