Home > OS >  Xamarin.Forms.Maps nested inside a ScrollView. Map not usable since ScrollView is intercepting event
Xamarin.Forms.Maps nested inside a ScrollView. Map not usable since ScrollView is intercepting event

Time:10-13

Xamarin Android.

I have searched and tried many answers from other threads but can not get it to work.

I have been trying to use RequestDisallowInterceptTouchEvent(true); to stop my parent ScrollView from absorbing the Touch Events and allow panning on the MapView thats nested inside it but not successful.

Here is what I have done so far in my Maps Customer Renderer for Android

private IViewParent _scrolLView;

    private IViewParent GetParentScrollView(IViewParent parent)
    {
        if (parent is ScrollViewRenderer)
            return parent;
        return GetParentScrollView(parent.Parent);
    }

    public override bool DispatchTouchEvent(MotionEvent e)
    {
        GetParentScrollView(Parent).RequestDisallowInterceptTouchEvent(true);
        return base.DispatchTouchEvent(e);
    }

But when I try to pan on the Map, the scroll view still intercepts and scrolls.

CodePudding user response:

RequestDisallowInterceptTouchEvent is called when a child does not want this parent and its ancestors to intercept touch events .

Try to change GetParentScrollView(Parent) to this , it works on my side .

 public override bool DispatchTouchEvent(MotionEvent e)
    {
        this.RequestDisallowInterceptTouchEvent(true);
        return base.DispatchTouchEvent(e);
    }
  • Related