public void OnReceiveValue(Java.Lang.Object value) { System.Diagnostics.Debug.WriteLine("value=[" + value + "]"); var height = Convert.ToInt32(value.ToString()); int specWidth = MeasureSpecFactory.MakeMeasureSpec(webView.ContentWidth, MeasureSpecMode.Exactly); int specHeight = MeasureSpecFactory.MakeMeasureSpec(height + 36, MeasureSpecMode.Exactly); webView.Measure(specWidth, specHeight); webView.Layout(0, 0, webView.MeasuredWidth, webView.MeasuredHeight); var bitmap = Bitmap.CreateBitmap(webView.DrawingCache); if (!_dir.Exists()) { _dir.Mkdir(); } var path = _dir.Path + "/" + _fileName + ".png"; var file = new Java.IO.File(path); if (!file.Exists()) { file.CreateNewFile(); } var stream = new FileStream(file.Path, FileMode.Create, System.IO.FileAccess.Write); bitmap.Compress(Bitmap.CompressFormat.Png, 80, stream); stream.Flush(); stream.Close(); _onComplete?.Invoke(path); }
public void OnReceiveValue(Java.Lang.Object value) { System.Diagnostics.Debug.WriteLine("value=[" + value + "]"); var height = Convert.ToInt32(value.ToString()); int specWidth = MeasureSpecFactory.MakeMeasureSpec(webView.ContentWidth, MeasureSpecMode.Exactly); int specHeight = MeasureSpecFactory.MakeMeasureSpec(height + 36, MeasureSpecMode.Exactly); webView.Measure(specWidth, specHeight); webView.Layout(0, 0, webView.MeasuredWidth, webView.MeasuredHeight); System.Diagnostics.Debug.WriteLine("spec [" + specWidth + ", " + specHeight + "]"); System.Diagnostics.Debug.WriteLine("webView.Measured [" + webView.MeasuredWidth + ", " + webView.MeasuredHeight + "]"); System.Diagnostics.Debug.WriteLine("webView.Layout [" + webView.Left + ", " + webView.Top + ", " + webView.Width + ", " + webView.Height + "]"); Complete(); }