zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

WebView的截屏实现

webview 实现 截屏
2023-09-11 14:20:45 时间

 WebView的截屏主要有两种实现方式:

  方式1:

   bitmap = webView.getDrawingCache(); 

  可是,webView必需要mWebView.setDrawingCacheEnabled(true);

 此方式仅仅能截取屏幕显示的内容

  方式2:

Picture snapShot = webView.capturePicture();  
    bitmap = Bitmap.createBitmap(snapShot.getWidth(),snapShot.getHeight(), Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(bitmap);  
    snapShot.draw(canvas); 

此方式能够将webview全部内容都进行截取。