我想拍攝我的活動和活動(視圖)組件的屏幕截圖。在Android中使用Sreen-shot
此活動包含一個SurfaceView和一個佈局在彼此的頂部。
當我拍攝表面視圖的屏幕截圖時效果很好,但是當我拍攝整個活動的屏幕截圖時,我沒有看到它的表面視圖。我使用下面的代碼:
public class Screenshot {
private final View view;
/** Create snapshots based on the view and its children. */
public Screenshot(View root) {
this.view = root;
}
/** Create snapshot handler that captures the root of the whole activity. */
public Screenshot(Activity activity) {
final View contentView = activity.findViewById(android.R.id.content);
this.view = contentView.getRootView();
}
/** Take a snapshot of the view. */
public Bitmap snap() {
Bitmap bitmap = Bitmap.createBitmap(this.view.getWidth(), this.view.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
return bitmap;
}
}
Nopes ..它不包括截圖中的SurfaceView。 – Kamal 2012-07-18 10:56:46