Capture WebView image and display in ImageButton

0

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

    
asked by anonymous 09.03.2015 / 17:12

1 answer

1

As you answer 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);
    }
});
    
09.03.2015 / 17:36