2
我遇到了2種製作屏幕截圖的方法。捕獲屏幕截圖的正確方法
我想知道,
- 什麼是兩個例子之間的不同?哪種方法是正確的?
- 將示例1可能有資源/內存泄漏問題?
實施例1
View v = rootView.findViewById(R.id.layout1);
if (v != null) {
v.setDrawingCacheEnabled(true);
Bitmap bitmap = v.getDrawingCache();
canvas.drawBitmap(bitmap, dummyMatrix, null);
// Possible resource/ memory leak?
}
實施例2
View v = rootView.findViewById(R.id.layout1);
if (v != null) {
v.buildDrawingCache();
Bitmap bitmap = v.getDrawingCache();
canvas.drawBitmap(bitmap, dummyMatrix, null);
v.destroyDrawingCache();
}