Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

swipe/fling inside Scrollview

$
0
0

I know this has been raised before but other threads do not seem to offer any conclusive solution - I tried thedispatchontouchevent override butI think the only reall solution is to extend the scrollview class and interceptthe left right swipe I've done this up to a point (not my comfort zone because all of the advice on the web is for Java dialect) Anyway got something which compiled but wont run. Anyone any idea what might be wrong with this code

public class ScrollViewEx : ScrollView { private float xDistance, yDistance, lastX, lastY;

    public ScrollViewEx(Context context, Android.Util.IAttributeSet attrs) 
    :base(context, attrs)
        {

        }


    public override bool OnInterceptTouchEvent(MotionEvent ev1)

    {

        base.OnInterceptTouchEvent(ev1);

            switch (ev1.Action) {

            case MotionEventActions.Down:

            xDistance = yDistance = 0f;
            lastX = ev1.GetX();
            lastY = ev1.GetY();
            break;

            case (MotionEventActions.Move):

            float curX = ev1.GetX();
            float curY = ev1.GetY();
            xDistance += System.Math.Abs(curX - lastX);
            yDistance += System.Math.Abs(curY - lastY);
            lastX = curX;
            lastY = curY;
            break;

            default:
            break;
            }
            if (xDistance > yDistance)
                return false;

return base.OnInterceptTouchEvent(ev1);

}

TiA

JohnM


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>