Issue
I have a webview in Xamarin Forms app for render html content and privacy policy. I'am facing two issues, that are follows.
- Content page or page popups are not respond to the click action.
- Images are displayed in the page are in bigger size and I'am not able to scroll those image horizontally.
Note: In iOS everything is working fine, no issues.
Pleas see my droid render implementation.
public override bool DispatchTouchEvent(MotionEvent e)
{
RequestDisallowInterceptTouchEvent(true);
return base.OnTouchEvent(e);
}
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
if (null == e.OldElement)
{
var webView = Element as CustomWebView;
Control.SetBackgroundColor(Android.Graphics.Color.Transparent);
Control.Settings.AllowUniversalAccessFromFileURLs = true;
Control.Settings.BuiltInZoomControls = true;
Control.Settings.DisplayZoomControls = true;
Control.Settings.JavaScriptEnabled = true;
Control.Settings.DomStorageEnabled = true;
Control.Settings.EnableSmoothTransition();
Control.Settings.SetSupportMultipleWindows(true);
Control.SetWebViewClient(new ExtendedWebViewClient(webView));
Control.SetWebChromeClient(new MyWebChromeClient());
Control.LoadUrl(control.Uri);
}
}
I have tried different options but no luck. Any help will be really appreciated.
Solution
Please disable DispatchTouchEvent method.Just use webView.Settings.UseWideViewPort=true;
in your WebViewRenderer
.
You can use following code in your WebViewRenderer
var webView = (global::Android.Webkit.WebView)Control;
webView.Settings.UseWideViewPort=true;
If I have long button. if I add this attribute, here is running GIF.
Answered By - Leon Lu - MSFT
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.