我想截取嵌套(中间)主布局的布局的屏幕截图。我正在使用以下代码:
public static Bitmap captureScreen(View v) {
Bitmap bitmap = null;
try {
if (v != null) {
int width = v.getWidth();
int height = v.getHeight();
screenshot = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
v.draw(new Canvas(screenshot));
}
} catch (Exception e) {
Log.d("captureScreen", "Failed");
}
return bitmap;
}
在按钮点击它会像:
captureScreen(midlayout);