Skip to content

Instantly share code, notes, and snippets.

@Kisty
Last active August 29, 2015 14:19
Show Gist options
  • Save Kisty/e2c3cd956a01a19661e8 to your computer and use it in GitHub Desktop.
Save Kisty/e2c3cd956a01a19661e8 to your computer and use it in GitHub Desktop.
Programatically scroll to a position in a ListView
public void scrollToPosition(ListView lv, int position, boolean clipToPadding) {
scrollToPositionFromTop(lv, position, 0, clipToPadding);
}
public void scrollToPositionFromTop(ListView lv, int item, int y, boolean clipToPadding) {
//Had to apply this offset if clipToPadding="false"
if (!clipToPadding) {
item -= lv.getPaddingTop();
}
this.setSelectionFromTop(position, y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment