I need to capture a webView.capturePicture
screenshot to the button click and display in a ImageButton
, how to do this?
I need to capture a webView.capturePicture
screenshot to the button click and display in a ImageButton
, how to do this?
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);
}
});