How To Capture The Webview To Bitmap In Android 5.0?
here i have a quick question on webview. My requirement is capture the webview and save the file in sdcard to that i used below code. Below code for generating Bitmap from webview
Solution 1:
U can draw the view on a canvas like this:
Bitmap mBitmap;
Layout webViewContainermBitmap= Bitmap.createBitmap(webViewContainer.getWidth(), webViewContainer.getHeight(), Bitmap.Config.ARGB_8888);
Canvascanvas=newCanvas(mBitmap);
webViewContainer.draw(canvas);
Solution 2:
You need to call WebView.enableSlowWholeDocumentDraw() before creating any WebViews. That is, if you have any WebViews in your layout, make sure you call this method before calling setContentView() in your onCreate() shown below.
if (Build.VERSION.SDK_INT >= 21) {
webview.enableSlowWholeDocumentDraw ();
}
its working fine for me..
Post a Comment for "How To Capture The Webview To Bitmap In Android 5.0?"