如何使用的onDraw(Canvas)的获得的WebView的位图快照(Android版) [英] How to use onDraw(Canvas) to obtain a bitmap snapshot of the WebView(Android)
本文介绍了如何使用的onDraw(Canvas)的获得的WebView的位图快照(Android版)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以前用capturePicture()方法,使我的WebView的快照。
这种方法去precated在API级别19。
I used to use capturePicture() method to make a snapshot of my WebView. This method was deprecated in API level 19.
doc文件说,使用的onDraw(Canvas)的获得的WebView的位图快照,但我真的不知道它是怎么意思。
The doc say that "Use onDraw(Canvas) to obtain a bitmap snapshot of the WebView", but I really don't know how it means.
请你教我如何解决这个问题?
Will you please teach me how to solve the problem?
推荐答案
下面应该工作:
float scale = webView.getScale();
int webViewHeight = (int)(webView.getContentHeight() * scale);
Bitmap image = Bitmap.createBitmap(webView.getWidth(), webViewHeight, Config.ARGB_8888);
Canvas canvas = new Canvas(image);
webView.draw(canvas);
这篇关于如何使用的onDraw(Canvas)的获得的WebView的位图快照(Android版)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文