The snapshots and screenshots of Android WebView are already numerous and are briefly recorded here:
1. Snapshots, generally when we use WebView, the Web page enlarges, some will not be displayed on the screen, if we want to intercept the entire webview display, we can use this, the code is as follows:
/*** Snapshot * *@paramContext *@return */ PrivateBitmap Capturescreen (Activity context) {
View SnapShot = Context.getwindow (). Getdecorview (); This method can also try the picture SnapShot=mwebview.capturepicture (); Bitmap BMP=Bitmap.createbitmap (Snapshot.getwidth (), Snapshot.getheight (), config.argb_8888); Canvas Canvas=NewCanvas (BMP); Snapshot.draw (canvas); returnbmp; }
2. To intercept the display part of the screen, the screen is not naturally intercepted, the code is as follows:
/** * Intercept the WebView visual area of the * @param webView premise:WebView to set webview.setdrawingcacheenabled (true); * @return * /private Bitmap capturewebviewvisiblesize (WebView WebView) { Bitmap bmp = Webview.getdrawingcache (); return bmp;}
Note that it is marked with a red part.
Android Snapshots and screenshots