boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)方法详解

博客提及在某方法中,distanceX和distanceY代表两次时间在X、Y轴上的距离,还提到了相关设置情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

* @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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值