I\'ve been trying for a while to get smoothScrollToPositionFromTop() working, but it doesn\'t always scroll to the correct position.
I\'ve got a ListView (with 10 i
Here is an implementation of the solution.
void smoothScrollToPositionFromTopWithBugWorkAround(final AbsListView listView,
final int position,
final int offset,
final int duration){
//the bug workaround involves listening to when it has finished scrolling, and then
//firing a new scroll to the same position.
//the bug is the case that sometimes smooth Scroll To Position sort of misses its intended position.
//more info here : https://code.google.com/p/android/issues/detail?id=36062
listView.smoothScrollToPositionFromTop(position, offset, duration);
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if(scrollState==OnScrollListener.SCROLL_STATE_IDLE){
listView.setOnScrollListener(null);
listView.smoothScrollToPositionFromTop(position, offset, duration);
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
}