0

I've been doing some research and haven't found a functional solution.

In short, I need to programmatically scrollTo a position in a scrollView (horizontal if anyone wants to know), without animating/seeing the animation. scrollTo performs the animation. Everything I have tried thus far is visibly scrolling the scrollView. I want to be able to instantly set a location for it to jump to.

Anyone have any suggestions?

joels
  • 1,292
  • 15
  • 21

3 Answers3

1

These are the diffrent methods to set scroll posiotion/location

ScrollView.scrollTo(int x, int y);
ScrollView.smoothScrollTo(int x, int y);
ScrollView.smoothScrollBy(int x, int y);

Try one of them. Hope It will help you.

Ankit Kumar
  • 3,663
  • 2
  • 26
  • 38
  • Thanks Ankit Kumar. I was aware of the smoothScrolls but they were obviously not what I was looking for. I got it working using the scrollTo method and some additional help. See my answer shortly. – joels Apr 24 '15 at 21:28
1

In the end, I achieved an "instant scroll" by using scrollView.scrollTo(x,y)

However, it did not work alone. To get it working without seeing a scroll animation, I had to perform my logic only when I knew the scrollView stopped. I implemented what tulio84z suggested in his answer

By knowing when my scrollView finished scrolling, I was able to then use scrollTo without seeing any scrolling animations.

Community
  • 1
  • 1
joels
  • 1,292
  • 15
  • 21
0

Use scrollBy (int x, int y) if you want to scroll immediately.

inmyth
  • 8,880
  • 4
  • 47
  • 52
  • Thanks for the suggestion. I ended playing with both scrollBy and scrollTo and got it working using scrollTo. – joels Apr 24 '15 at 21:22