/// <summary> /// Called when [element changed]. /// </summary> /// <param name="e">The e.</param> protected override void OnElementChanged(ElementChangedEventArgs <HybridWebView> e) { base.OnElementChanged(e); if (this.Control == null) { var webView = new NativeWebView(this); webView.Settings.JavaScriptEnabled = true; //Turn off hardware rendering webView.SetLayerType(LayerType.Software, null); //Set the background color to transparent to fix an issue where the //the picture would fail to draw webView.SetBackgroundColor(Color.Transparent.ToAndroid()); webView.SetWebViewClient(this.GetWebViewClient()); webView.SetWebChromeClient(this.GetWebChromeClient()); webView.AddJavascriptInterface(new Xamarin(this), "Xamarin"); this.SetNativeControl(webView); webView.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); } this.Unbind(e.OldElement); this.Bind(); }
/// <summary> /// Called when [element changed]. /// </summary> /// <param name="e">The e.</param> protected override void OnElementChanged(ElementChangedEventArgs <HybridWebView> e) { base.OnElementChanged(e); if (this.Control == null) { var webView = new NativeWebView(this); webView.Settings.JavaScriptEnabled = true; webView.SetWebViewClient(new Client(this)); webView.SetWebChromeClient(new ChromeClient(this)); webView.AddJavascriptInterface(new Xamarin(this), "Xamarin"); this.SetNativeControl(webView); } this.Unbind(e.OldElement); this.Bind(); }