0

My Gesture Detector Code: It's all Simple pre-defined code

private final GestureDetector.SimpleOnGestureListener mGestureListener
        = new GestureDetector.SimpleOnGestureListener() {

    @Override
    public boolean onDown(MotionEvent e) {ViewCompat.postInvalidateOnAnimation(FractionalLinearLayout.this);
        return true;
    }

    @Override
    public boolean onScroll(MotionEvent e1, MotionEvent e2,
                            float distanceX, float distanceY) {
        /**
         * Pixel offset is the offset in screen pixels, while viewport offset is the
         * offset within the current viewport. For additional information on surface sizes
         * and pixel offsets, see the docs for {@link computeScrollSurfaceSize()}. For
         * additional information about the viewport, see the comments for
         * {@link mCurrentViewport}.
         */

        Log.d("Testing Scroll", ""+distanceY);

        if(mParentView != null && mParentView.getId() == R.id.container && (distanceY>10 || distanceY<-10)){
            mParentView.scrollBy(0, (int)distanceY);
        }
        ViewCompat.postInvalidateOnAnimation(FractionalLinearLayout.this);

        return true;
    }

    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
        mScroller.fling(getScrollX(), getScrollY(),
                -(int) velocityX, -(int) velocityX, 0, 0, 0, 0);
        ViewCompat.postInvalidateOnAnimation(FractionalLinearLayout.this);
        return true;
    }
};

mParentView is the parentView of this layout And my Output Animation in Video format : Jaggy Scrolling

what is causing such jaggedness in my scrolling?

phoenisx
  • 1,507
  • 17
  • 28
  • #Subroto Biswas (Pikachu) Have a look here http://stackoverflow.com/questions/11421368/android-fragment-oncreateview-with-gestures & http://stackoverflow.com/questions/22981337/detect-swipe-gesture-in-fragment – IntelliJ Amiya Jan 25 '16 at 11:14
  • I don't have problems getting onFling() or onScroll() callbacks, my problem is when the onScroll gesture is called, which part of the example code gets run to invalidate the view, so as to make a Scroll effect. After my debugging, i can only understand that **fling()** method is somehow related to onScroll() event – phoenisx Jan 26 '16 at 03:19

0 Answers0