cardBackgroundColor
设置为透明色:
...
View root = findViewById(android.R.id.content);
Bitmap screenshot = takeScreenshot(root);
public static Bitmap takeScreenshot(View view) {
view.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
view.setDrawingCacheEnabled(false);
return bitmap;
}
注意:为了避免截图中出现状态栏等浮层,建议在截图之前隐藏不必要的 View。