问题
I used to use capturePicture() method to make a snapshot of my WebView. This method was deprecated in API level 19.
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?
回答1:
The following should work:
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);
来源:https://stackoverflow.com/questions/19856832/how-to-use-ondrawcanvas-to-obtain-a-bitmap-snapshot-of-the-webviewandroid