Question

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?

Was it helpful?

Solution

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?

OTHER TIPS

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.

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);
            }
        }
    });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top