【发布时间】:2013-05-08 08:21:16
【问题描述】:
我想知道如何从 SupportMapFragment 获取快照。我不知道。请帮忙。
感谢您的提前。
【问题讨论】:
标签: android google-maps-android-api-2 supportmapfragment
我想知道如何从 SupportMapFragment 获取快照。我不知道。请帮忙。
感谢您的提前。
【问题讨论】:
标签: android google-maps-android-api-2 supportmapfragment
要获得可绘制对象,您可以实现以下代码:
SnapshotReadyCallback callback = new SnapshotReadyCallback() {
@Override
public void onSnapshotReady(Bitmap snapshot) {
mapSnapshot = snapshot;
}
};
googleMap.snapshot(callback);
Drawable screenshot = new BitmapDrawable(getResources(),mapSnapshot);
如果您直接想将快照保存在SD上,您可以按照这个答案: Capture screen shot of GoogleMap Android API V2
【讨论】:
latest update of Google Play Services library 使我们能够通过 GoogleMap 的snapshot() 方法制作快照。
【讨论】:
您可以尝试截取片段视图的屏幕截图:
View view = findViewById(R.id.fragmentId);
view.setDrawingCacheEnabled(true);
Bitmap bitmap = view.getDrawingCache();
BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
我没有测试过。
【讨论】: