如何从表面视图创建和保存屏幕截图? [复制]

2024-01-10

我有一个应用程序,我希望能够捕获屏幕截图

这是我的代码:

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;
    }

}

但surfaceView的内容保存为black.!!!

请帮帮我,谢谢...


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何从表面视图创建和保存屏幕截图? [复制] 的相关文章

随机推荐