shenhb
2019-07-15 14:58:54 +08:00
java 代码
`
private Bitmap captureWebView(WebView webView) {
int wholeWidth = webView.computeHorizontalScrollRange();
int wholeHeight = webView.computeVerticalScrollRange();
Bitmap x5bitmap = Bitmap.createBitmap(wholeWidth , wholeHeight, Bitmap.Config.ARGB_8888);
Canvas x5canvas = new Canvas(x5bitmap);
x5canvas.scale((float) wholeWidth / (float) webView.getContentWidth(), (float) wholeHeight / (float)webView.getContentHeight());
if ( webView.getX5WebViewExtension() == null) {
return null;
}
webView.getX5WebViewExtension().snapshotWholePage(x5canvas, false, false);
return x5bitmap;
}
`