Android: How to detect when a scroll has ended

后端 未结 14 850
误落风尘
误落风尘 2020-11-27 10:54

I am using the onScroll method of GestureDetector.SimpleOnGestureListener to scroll a large bitmap on a canvas. When the scroll has ended I want to redraw the bitmap in case

14条回答
  •  时光取名叫无心
    2020-11-27 11:52

    I think this will work as you need

    protected class SnappingGestureDetectorListener extends SimpleOnGestureListener{
    
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY){
            boolean result = super.onScroll(e1, e2, distanceX, distanceY);
    
            if(!result){
                //Do what you need to do when the scrolling stop here
            }
    
            return result;
        }
    
    }
    

提交回复
热议问题