private Bitmap get3(){ //获取webview缩放率 WebView wv_capture = mWebView; float scale = wv_capture.getScale(); //得到缩放后webview内容的高度 int webViewHeight = (int) (wv_capture.getContentHeight()*scale); int width = wv_capture.getWidth(); longImage = Bitmap.createBitmap(wv_capture.getWidth(),webViewHeight, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(longImage); //绘制 wv_capture.draw(canvas); try { String fileName = Environment.getExternalStorageDirectory().getPath()+"/webview_capture4.jpg"; FileOutputStream fos = new FileOutputStream(fileName); //压缩bitmap到输出流中 longImage.compress(Bitmap.CompressFormat.JPEG, 70, fos); fos.close(); } catch (Exception e) { Log.e(TAG, e.getMessage()); }finally { } return longImage; }
webview长截图
最新推荐文章于 2020-01-03 17:47:27 发布