i have a webview and i have tried to use tap gesture however it was unresponsive therefore i have decided to use box view around the webview which works fine and i am able to scroll and tap the box view. However once i scroll on the bottom and the following content is not that long to be scrolled i am still at the end of the vebview and have to scroll to the top to actually view the content. Its hard to explain but basically if i have very long sentence i can scroll downr secons sentence is only few words and i have to scroll to the top. I need that to be done automatically. Do you have any experience with this?
[assembly: ExportRenderer(typeof(ExtendedWebView), typeof(ExtendedWebViewRenderer))]
namespace Droid.Renderers
{
public class ExtendedWebViewRenderer : WebViewRenderer
{
public static int _webViewHeight;
static ExtendedWebView _xwebView = null;
WebView _webView;
WebView _webView;
public async override void OnPageFinished(WebView view, string url)
{
try
{
_webView = view;
if (_xwebView != null)
{
view.Settings.JavaScriptEnabled = true;
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
_xwebView = e.NewElement as ExtendedWebView;
_webView = Control;
if (e.OldElement == null)
{
_webView.SetWebViewClient(new ExtendedWebViewClient());
}
}
}
}
Shared project
public class ExtendedWebView : WebView
{
public ICommand PannedCommand
{
set { SetValue(PannedCommandProperty, value); }
get { return (ICommand)GetValue(PannedCommandProperty); }
}
public static readonly BindableProperty PannedCommandProperty = BindableProperty.Create(nameof(PannedCommand), typeof(ICommand), typeof(ExtendedWebView));
}
See Question&Answers more detail:os