Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9104809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:57:01+00:00 2026-06-17T01:57:01+00:00

I think the title pretty much covers it, but I have a webview in

  • 0

I think the title pretty much covers it, but I have a webview in my activity. I’ve loaded a url into the webview and I’d like to take a screenshot of the full page (whatever is in the viewport and the stuff “below the fold” as well).

I’ve got code that works to snapshot the viewport, and I know this can be done in iOS by enlarging the webview before snapshotting it. I’ve tried to use the same technique here:

    WebView browserView = (WebView) findViewById(R.id.browserView);

    //Resize the webview to the height of the webpage
    int pageHeight = browserView.getContentHeight();
    LayoutParams browserParams = browserView.getLayoutParams();
    browserView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, pageHeight));

    //Capture the webview as a bitmap
    browserView.setDrawingCacheEnabled(true);
    Bitmap bitmap = Bitmap.createBitmap(browserView.getDrawingCache());
    browserView.setDrawingCacheEnabled(false);

    //Create the filename to use
    String randomFilenamepart = String.valueOf(new SecureRandom().nextInt(1000000));
    String filename = Environment.getExternalStorageDirectory().toString() + "/Screenshot_" + randomFilenamepart + ".jpg";
    File imageFile = new File(filename);
    //Stream the file out to external storage as a JPEG
    OutputStream fout = null;
    try {
        fout = new FileOutputStream(imageFile);
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
        fout.flush();
        fout.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        browserView.setLayoutParams(browserParams);
    }

But I’m still only capturing just the viewport. Disregarding things like running out of memory because the page is too large, does anyone know what I’m doing wrong or how I can include the portion outside the viewport?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T01:57:02+00:00Added an answer on June 17, 2026 at 1:57 am

    Try this one

    import java.io.FileOutputStream;
    
    import android.app.Activity;
    import android.graphics.Bitmap;
    import android.graphics.Canvas;
    import android.graphics.Picture;
    import android.os.Bundle;
    import android.view.Menu;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;
    
    public class MainActivity extends Activity {
    
        WebView w;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            w = new WebView(this);
            w.setWebViewClient(new WebViewClient() {
                public void onPageFinished(WebView view, String url) {
                    Picture picture = view.capturePicture();
                    Bitmap b = Bitmap.createBitmap(picture.getWidth(),
                            picture.getHeight(), Bitmap.Config.ARGB_8888);
                    Canvas c = new Canvas(b);
    
                    picture.draw(c);
                    FileOutputStream fos = null;
                    try {
    
                        fos = new FileOutputStream("mnt/sdcard/yahoo.jpg");
                        if (fos != null) {
                            b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
    
                            fos.close();
                        }
                    } catch (Exception e) {
    
                    }
                }
            });
    
            setContentView(w);
            w.loadUrl("http://search.yahoo.com/search?p=android");
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }
    }
    
    

    Add INTERNET PERMISSION and WRITE_EXTERNAL_STORAGE in AndroidManifest.xml file.

    Need to ask permission at run time for file write if app is running on or above Marshmallow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Pretty much what the title says. I have a list of Integers like so:
Title pretty much sums it up, I think. I'd like to know if it's
OK, I don't think the title says it right... but here goes: I have
The title pretty much says it all. I have a project that for political
Pretty much what the title says. I have got a checkbox which on checked
I think the title pretty much nails it. I am using a Char(36) in
I think the title of my question pretty much sums it all up. I'm
the title pretty much says it all. I have a cube with data in
The title pretty much states my question. I have a view (say, Action1 )
hey the title pretty much says it all. i have been trying different methods

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.