* @param e1 The first down motion event that started the scrolling. * @param e2 The move motion event that triggered the current onScroll.
* @param distanceX The distance along the X axis that has been scrolled since the last * call to onScroll. This is NOT the distance between {@code e1} * and {@code e2}. * @param distanceY The distance along the Y axis that has been scrolled since the last * call to onScroll. This is NOT the distance between {@code e1} * and {@code e2}.
可以看出,在
boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);
方法中,distanceX,和distanceY就是两次时间X,Y轴上的距离
设置是可以为:
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
//从之前的基础上开始
currentMaxtrix.set(imageView.getImageMatrix());
matrix.set(currentMaxtrix);
//进行移动
matrix.preTranslate((int)(-1)*distanceX,(int)(-1)*distanceY);
//重新设置图片位置
imageView.setImageMatrix(matrix);
return true;
}