Search code examples
androidlistviewsmooth-scrolling

Android smoothScrollToPosition up top


I have set up smoothScrollToPosition on a listview and it works perfect! However... I would rather it put the position at the top of the listview rather than just on the screen (mostly on the bottom if its needed to scroll down). Any ideas how i can accomplish this?


Solution

  • Use smoothScrollToPositionFromTop(). It places the item at the specified position a specified number of pixels from the top of the ListView (if possible). You should simply supply a small offset.

    Note: requires API level 11+.