I use below code to take screenshot from a WebView
. it works well in Android 6 and lower versions but in Android 7 it takes only the visible part of the webview.
// before setContentView
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
WebView.enableSlowWholeDocumentDraw();
}
...
// before set webview url
webView.setDrawingCacheEnabled(true);
// after html load complete
final Bitmap b = Bitmap.createBitmap(webView.getMeasuredWidth(),
webView.getContentHeight(), Bitmap.Config.ARGB_8888);
Canvas bitmapHolder = new Canvas(b);
webView.draw(bitmapHolder);
but bitmap b is not complete. How can I take screenshot of whole WebView
in Android Nougat?
Edit:
I found out the webView.getContentHeight
doesn't works well. I hard coded the whole webview
height and it works well. So the Question is : How can I get the Whole WebView
Content Height in Android Nougat?