0

I am trying to capture an image of the WebView component as it displays a web page.

Why is the width always 800:

Picture screenie = webview.capturePicture();
Log.d(TAG, "W: " + screenie.getWidth() + " H: " + screenie.getHeight());
// 800 x 1200

I've changed the AVD resolution to 480 and many other combinations. I've used different built in skins too. Am I missing something?

I'm also using:

webview.getSettings().setLoadWithOverviewMode(true);
webview.getSettings().setUseWideViewPort(true);
Abs
  • 56,052
  • 101
  • 275
  • 409

2 Answers2

1

You can try something like this : int imageWidth, imageHeight;

Bitmap result = Bitmap.createScaledBitmap(bitmapPicture,
                        imageWidth, imageHeight, false);

Here you can add your own width and height. bitmapPicture is the object of Bitmap.

let me know, if this is of any help to you.

Shishir Shetty
  • 2,021
  • 3
  • 20
  • 35
0

capturePicture captures the current contents of the view, not the screen. So as the documents say it returns "a picture containing the current contents of the view. Note this picture is of the entire document, and is not restricted to the bounds of the view."

Torid
  • 4,176
  • 1
  • 28
  • 29
  • So you are saying there is no way to set width or confine it somehow? It will always give me a width of whatever the contents width is? – Abs Jan 17 '12 at 13:52
  • I'm saying that capturePicture always captures the entire View - where the View is the underlying WebView contents, not the display. If you haven't played around with the size of the View, you will get the whole View / contents. There may be ways of changing the View size, but I don't know what they are. Check out http://stackoverflow.com/questions/3808532/how-to-set-the-initial-zoom-width-for-a-webview or search. – Torid Jan 18 '12 at 17:41