Android-based long screenshots with content beyond the screen size

Source: Internet
Author: User

Android-based long screenshots with content beyond the screen size

Try everything, just stay at the level of imagination, that is also equivalent to waste of time, do not take it for granted

First look at the requirements:

When the content is beyond the display range of the mobile phone, you must intercept all the content to generate the so-called "length ".

There is no difficulty. We use the features of webview and scrollview rendering to generate bitmap.

Main Code:

// This is the public static Bitmap getBitmapByView (scrollview ScrollView) of scrollView {int h = 0; Bitmap bitmap = null; for (int I = 0; I <scrollView. getChildCount (); I ++) {h + = scrollView. getChildAt (I ). getHeight (); scrollView. getChildAt (I ). setBackgroundColor (Color. parseColor ("# ffffff");} bitmap = Bitmap. createBitmap (scrollView. getWidth (), h, Bitmap. config. RGB_565); final Canvas canvas = new Canvas (bitmap); scrollView. draw (canvas); return bitmap;}/*** mScrollView ** @ param context * @ param scrollView */public static void scrollviewContent2Png (Context context, ScrollView scrollView) {Bitmap bmp = null; bmp = getBitmapByView (scrollView); saveBitmapToCamera (context, bmp, null );}
// This Is A webview. The webview's apiprivate static Bitmap captureWebView (WebView webView) {Picture snapShot = webView is used. capturePicture (); Bitmap bmp = Bitmap. createBitmap (snapShot. getWidth (), snapShot. getHeight (), Bitmap. config. ARGB_8888); Canvas canvas = new Canvas (bmp); snapShot. draw (canvas); return bmp ;}

Simple ?....

The code is rough and only implements the function part. When the image is generated, no threads are used. If there are other good solutions, you can communicate with each other:

Download the demo

http://download.csdn.net/detail/jarlen/8910051

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.