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

我的未来我决定 提交于 2019-12-09 05:58:05

问题


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"/>


来源:https://stackoverflow.com/questions/14218124/new-gms-maps-mapview-rendering-lags-a-bit-when-in-a-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!