android - 为什么通过代码在Android中截取多个 View 时VideoView是黑色的?

标签 android view android-videoview

在我的 Android 应用程序中,我有多个 View 同时运行:ImageView、VideoView 和 WebView。但是,当我通过代码截屏时,VideoView 是黑色的,而使用 Android 设备手动截屏时则不会出现这种情况。

为什么会这样?

使用的代码:

 try {
        View view = getActivity().getWindow().getDecorView().getRootView();
        view.setDrawingCacheEnabled(true);

        Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
        view.setDrawingCacheEnabled(false);

        File imageFile = new File(mPath);

        FileOutputStream outputStream = new FileOutputStream(imageFile);
        int quality = 100;
        bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
        outputStream.flush();
        outputStream.close();
    } catch (Throwable e) {
        e.printStackTrace();
    }

截图结果: Example of screenshot

最佳答案

尝试像这样使用 TextureVideoView:https://github.com/sprylab/texturevideoview

关于android - 为什么通过代码在Android中截取多个 View 时VideoView是黑色的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45990360/

相关文章:

android - 保持连接有效?

android - 办公 map 如室内地图

python - 如何修复 django 中的 GET 参数错误?

razor - 如何将 DbContext 从模型绑定(bind)到 View

android - 谁是服务的 "client"- 上下文或 ServiceConnection?

android - scrollBy() 不滚动

Android VideoView或SurfaceView播放视频?

android - 视频 View :Avoiding fullscreen black flash

fullscreen - Vitamio全屏视频查看

java - 使用磁传感器