I’m creating an app that primarily works with listviews. The user can add items to the listview and I want to scroll from the current position, down to the bottom of the list.
I initially used scrollBy(int x, int y) which was able to scroll down from the current position. However this was an instantaneous action. I would prefer it to be a smooth scroll.
So that’s exactly what I did. I used smoothScrollBy(int distance, int duration) but this always seems to scroll from the top, even when I set the current position in the list just before it.
My question is, should I use some timer which slows down the method scrollBy, or should there be a way to do smoothScrollBy where we start off at the current position we are in the list?
I should note that when I mean current position, I store the exact pixel position, not just setSelection(int position).
Thanks
Okay I solved the problem. The problem was caused elsewhere in my code.
The reason why it was always scrolling from the very top, is because I was updating the current list position immediately after calling smoothScrollBy(). As such it was updating before the scrolling action had been completed. I moved my method call which updates the list position later on in my code, and now it works fine.