Hi EJ-5254,
Welcome to our Microsoft Q&A platform!
If "strange behaviour" means that the scroll bar of the WebView cannot be used, you can try to solve this problem by adding a Renderer to WebView.
You can create the renderer For Android as follows.
[assembly: ExportRenderer(typeof(WebView), typeof(MyWebViewRenderer))]
namespace scrollview.Droid
{
public class MyWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
Control.Touch -= Control_Touch;
}
if (e.NewElement != null)
{
Control.Touch += Control_Touch;
}
}
void Control_Touch(object sender, Android.Views.View.TouchEventArgs e)
{
switch (e.Event.Action)
{
case MotionEventActions.Down:
Control.Parent.RequestDisallowInterceptTouchEvent(true);
break;
case MotionEventActions.Up:
Control.Parent.RequestDisallowInterceptTouchEvent(false);
break;
}
Control.OnTouchEvent(e.Event);
}
}
On iOS, the webview's scrollbar work fine without any renderer.
Update:
To enable to scroll the Editor in scrollview, you can create a listener and a custom renderer for it as follows. And here is the reference link.
[assembly: ExportRenderer(typeof(Editor), typeof(CustomEditorRenderer))]
namespace scrollview.Droid
{
class CustomEditorRenderer : EditorRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
{
base.OnElementChanged(e);
if (e.OldElement == null)
{
var nativeEditText = (global::Android.Widget.EditText)Control;
nativeEditText.OverScrollMode = OverScrollMode.Always;
nativeEditText.ScrollBarStyle = ScrollbarStyles.InsideInset;
nativeEditText.SetOnTouchListener(new CustomTouchListener());
Control.VerticalScrollBarEnabled = true;
Control.MovementMethod = ScrollingMovementMethod.Instance;
Control.ScrollBarStyle = Android.Views.ScrollbarStyles.InsideInset;
Android.Content.Res.TypedArray a = Control.Context.Theme.ObtainStyledAttributes(new int[0]);
InitializeScrollbars(a);
a.Recycle();
}
}
}
public class CustomTouchListener : Java.Lang.Object, Android.Views.View.IOnTouchListener
{
public bool OnTouch(Android.Views.View v, MotionEvent e)
{
v.Parent?.RequestDisallowInterceptTouchEvent(true);
if ((e.Action & MotionEventActions.Up) != 0 && (e.ActionMasked & MotionEventActions.Up) != 0)
{
v.Parent?.RequestDisallowInterceptTouchEvent(false);
}
return false;
}
}
}
Regards,
Kyle
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.