Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New gms.maps.MapView rendering lags a bit when in a ListView?

I'm trying to put an instance of the new MapView in a ListView. New mapview being:

com.google.android.gms.maps.MapView

I'm turning all interactions off, and setting a fixed height for the view:

GoogleMapOptions options = new GoogleMapOptions();
    options.mapType(GoogleMap.MAP_TYPE_NORMAL);
    options.compassEnabled(false);
    options.rotateGesturesEnabled(false);
    options.scrollGesturesEnabled(false);
    options.tiltGesturesEnabled(false);
    options.zoomControlsEnabled(false);
    options.zoomGesturesEnabled(false);

mMapView = new MapView(getActivity(), options);
mMapView.setLayoutParams(new AbsListView.LayoutParams(
    AbsListView.LayoutParams.MATCH_PARENT,
    200));
mMapView.setEnabled(false);
mMapView.setFocusable(false);
getListView().addHeaderView(mMapView);
getListView().addAdapter(simpleArrayAdapter);

This works, but if I scroll the listview quickly, it looks like the mapview rendering lags a bit, so you can see a small area of black pixels in the direction of scrolling.

It almost seems as if this is some kind of synchronization issue, as I'm guessing the mapview with opengl is fast enough to render in response to my scrolls. Also, the old MapView+MapActivity would perform fine in the same setup.

Below is a picture of the gap that appears when you scroll quickly. After a short time, the mapview will catch up and render ok again.

enter image description here

Any ideas on this?

Thanks

----- Update ---------

This issue looks to be the same as:

ViewPager with Google Maps API v2: mysterious black view

I could not get the fix documented there to work in this setup, though.

like image 563
user1219278 Avatar asked Jan 08 '13 15:01

user1219278


1 Answers

Put this in your manifest if your targeting API 13>

<application android:hardwareAccelerated="true"/>
like image 126
MoMo Avatar answered Oct 29 '22 21:10

MoMo