开发者

Way to check if user is scrolling?

开发者 https://www.devze.com 2023-02-16 21:57 出处:网络
I have a scrollview in my layout and I want to be able to check if the user is scrolling. I checked theScrollview in Androi开发者_如何学JAVAd Docs, but I don\'t see anything like isScrolling() that re

I have a scrollview in my layout and I want to be able to check if the user is scrolling. I checked the Scrollview in Androi开发者_如何学JAVAd Docs, but I don't see anything like isScrolling() that returns a boolean.

My question is: is there a way to check if the user is attempting to scroll, as opposed to clicking a button? Could there be some other class in the Android core that is monitoring the scroll event?


There could be a better way but here is how you can figure it out.

You get a MotionEvent object inside the onTouchEvent(MotionEvent ev) method. check the action of the motion event as ev.getAction().

If the action is ACTION_MOVE it implies that a scrolling is taking place.

Note: Scrolling is different than a fling. So the same logic cannot be used to determine if the fling is over.

0

精彩评论

暂无评论...
验证码 换一张
取 消