Capture Webview image and display in Imagebutton

Asked

Viewed 139 times

0

I need to capture a screenshot webView.capturePicture click button and display in a ImageButton, how to do this?

  • 1

    Capturing when you click the button.

  • Good afternoon, did my answer help you? Please let me know if you still have any questions. if not and the answer was helpful, please mark as "correct". Grateful.

1 answer

1

As this response from Soen, you will need the class Bitmap, Canvas and BitmapDrawable.

An example would be something like:

ImageButton imageBtn;
WebView myWebView;

...

btn.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
        Picture mPicture = myWebView.capturePicture();
        Bitmap mBitmap = Bitmap.createBitmap(
            picture.getWidth(), picture.getHeight(),
            Bitmap.Config.ARGB_8888
        );
        Canvas mCanvas = new Canvas(mBitmap);
        picture.draw(mCanvas);

        BitmapDrawable bd = new BitmapDrawable(mPicture);
        imageBtn.setBackgroundDrawable(bd);
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.