Android Snapshots and screenshots

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.