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

2019-03-20 07:36发布

问题:

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.

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.

回答1:

Put this in your manifest if your targeting API 13>

<application android:hardwareAccelerated="true"/>