Does smoothScrollToPosition() method for GridView works correctly?
I have found an open bug report and mine is not working correctly either.
setSelection() is working fine but I want a smooth scroll effect.
Do you have any idea about this issue?
If this is a persistent problem, where should I start to implement a good scroll effect?
While I’m not seeing any issues running the example code you posted, if you’re not seeing consistent results in your application it’s not too tricky to create your own scroll controller. Here’s an example implementation you could use:
Here’s a snippet from the example you linked that includes where this new class to do the scrolling in place of the framework implementation:
If you want to add a feature where the selected position is always scrolled to the top even when the scrolling direction is down, you could do that. This is not something the framework’s implementation is designed to do, but you could accomplish it by adding some code in
DIR_DOWNto continue scrolling until the first visible position matches target (likeDIR_UPdoes). You must also beware of the case where the scrolling ends before the position reaches the top, so you aren’t constantly posting the handler in cases where you will never get a different result.HTH