嘿,我只是想确定 scrollview 在 android 中是向上滚动还是向下滚动。想要在向上滚动和向下滚动时执行不同的操作。
任何想法表示赞赏, 谢谢
最佳答案
试试这个: 扩展 Scrollview 并覆盖 onTouchEvent 方法
private float mTouchPosition;
private float mReleasePosition;
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mTouchPosition = event.getY();
}
if (event.getAction() == MotionEvent.ACTION_UP) {
mReleasePosition = event.getY();
if (mTouchPosition - mReleasePosition > 0) {
// user scroll down
} else {
//user scroll up
}
}
return super.onTouchEvent(event);
}
关于android - 有什么方法可以识别 scrollview 在 android 中向上或向下滚动吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27860529/