在我的 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();
}
最佳答案
尝试像这样使用 TextureVideoView:https://github.com/sprylab/texturevideoview
关于android - 为什么通过代码在Android中截取多个 View 时VideoView是黑色的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45990360/