Arcgis for android 100.4截屏功能

/**
* 把一个MapView的对象转换成bitmap
*/
public static Bitmap getMapViewBitmap(MapView v) {

v.clearFocus();
v.setPressed(false);
//能画缓存就返回false
boolean willNotCache = v.willNotCacheDrawing();
v.setWillNotCacheDrawing(false);
int color = v.getDrawingCacheBackgroundColor();
v.setDrawingCacheBackgroundColor(0);
if (color != 0) {
v.destroyDrawingCache();
}
v.buildDrawingCache();
Bitmap cacheBitmap = null;
while(cacheBitmap == null){
final ListenableFuture<Bitmap> export = v.exportImageAsync();
try {
cacheBitmap =export.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
// Restore the view
v.destroyDrawingCache();
v.setWillNotCacheDrawing(willNotCache);
v.setDrawingCacheBackgroundColor(color);
return bitmap;
}
posted @ 2019-04-11 09:36  only_books  阅读(564)  评论(0编辑  收藏  举报