最近在做个项目,需要判断ScrollLayout滑动是否完成。查了些资料,很多人说只要判断:
computeScrollOffset()
这个方法就可以了,如果是true表示滑动完毕,否则表示滑动失败。
实际使用了下,发现是错误的,当滑动开始的时候,这个方法也返回true.
最后发现需要这么写才能判断,ScrollLayout滑动结束。
if (mScroller.computeScrollOffset()) {
scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
if (mScroller.isFinished()) {//判断结束的地方。
}
}