2017-08-31 96 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) –

回答

相關問題