2017-08-31 97 views
1

在我的Android应用程序中,我有多个视图同时运行:ImageView,VideoView和WebView。但是,当我通过代码截取屏幕截图时,VideoView是黑色的,手动使用Android设备截取屏幕时并非如此。为什么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

+0

'VideoView'不使用绘图缓存。系统截图机制不会使用您的代码来制作屏幕截图。 – CommonsWare

+0

[VideoView getDrawingCache可能重复黑色](https://stackoverflow.com/questions/5278707/videoview-getdrawingcache-is-returning-black) –

回答

相关问题