0

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.

Mable John
  • 4,518
  • 3
  • 22
  • 35
  • 2
    Please disable `DispatchTouchEvent` method. Just use `webView.Settings.UseWideViewPort=true;` in your `WebViewRenderer`, webview could be horizontal scrolled. Here is running GIF. https://imgur.com/a/zUD16pf – Leon May 13 '20 at 09:40
  • @LeonLu-MSFT Thanks. Working fine. Please post as an answer, so that I can mark your answer. – Mable John May 13 '20 at 10:16
  • @LeonLu-MSFT I felt little bit jerky effect while scrolling horizontally, is there any workaround. – Mable John May 13 '20 at 10:19
  • This little bit jerky effect may be related to the Android emulator, you can test it in Android device. – Leon May 13 '20 at 10:26
  • I post above comment to answer, please accept it as answer, it will help other who have similar issue. – Leon May 13 '20 at 11:30

1 Answers1

1

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.

enter image description here

Leon
  • 8,404
  • 2
  • 9
  • 52