Abs
Abs

Reputation: 57916

Android webview.capturePicture always the same width

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);

Upvotes: 0

Views: 1290

Answers (2)

Shishir Shetty
Shishir Shetty

Reputation: 2049

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.

Upvotes: 1

Torid
Torid

Reputation: 4196

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."

Upvotes: 0

Related Questions