Answer the question
In order to leave comments, you need to log in
How to take a snapshot of WebView content?
Nexus 5. Android Lollipop 5.1. Xamarin.
I use this code to save conversations from m.vk.com as images. These are not exactly screenshots, but a snapshot of the contents of the WebView. Sometimes they come out 20000px high, i.e. significantly larger than the visible area of the WebView. It used to work fine, but recently the snapshot is the same size, but it only has the visible area of the WebView and a bunch of gray background. I suspect that the reason is the WebView refresh. How can this be fixed?
public override void OnPageFinished (WebView view, string url)
{
Picture picture = view.CapturePicture ();
Bitmap bmp = Bitmap.CreateBitmap (picture.Width, picture.Height, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas (bmp);
picture.Draw (canvas);
MainActivity.Save(bmp);
}
Answer the question
In order to leave comments, you need to log in
usually such functionality is not cut out for a clean one (unless they thought it was a bug), so most likely they moved it into some kind of separate function.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question