Reputation: 114
How can I detect the end of a fling event within a HorizontalScrollView?
Using a GestureDetector, I can determine when onFling has started, but I can't figure out how to tell when it has completed. Is there any callback function or similar trick that I'm missing?
Upvotes: 1
Views: 4611
Reputation: 63
I hope this will work to visible and invisible the horizontal scrollView's scroll end
hsv.setOnScrollChangeListener(new View.OnScrollChangeListener() {
@Override
public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
View view = (View) hsv.getChildAt(hsv.getChildCount() - 1);
int diff = (view.getRight() - (hsv.getWidth() + hsv.getScrollX()));
if (diff <= 0) {
next.setVisibility(View.INVISIBLE);
} else {
next.setVisibility(View.VISIBLE);
}
}
});
Upvotes: 0
Reputation: 9606
This answer is late but probably useful with the similar requirements
My approach is to override scrollTo of the View. With I reschedule a delayed message using a Handler. The effect is that as long as scroll call happens the message will not be delivered. But when no scroll call happens the message will be delivered and could be used to signal the end of "flinging"
Did you get the idea?
Upvotes: 3
Reputation: 33792
Probably by detecting an over scroll
How about this :
Use a combination of onFling()
and onScrollChanged()
. When an fling event occurs AND a scrolling event follows, you will get the exact amount of change.
Upvotes: 0