Skip to content

Instantly share code, notes, and snippets.

@olkunmustafa
Created July 12, 2016 08:09
Show Gist options
  • Save olkunmustafa/f619f6c8af423bf1ce13a9aafd76f3ba to your computer and use it in GitHub Desktop.
Save olkunmustafa/f619f6c8af423bf1ce13a9aafd76f3ba to your computer and use it in GitHub Desktop.
Used when it is wanted to set selection listview with animation.
public void smootScroolListview() {
int duration = 300;//ms
int position = mListView.getFirstVisiblePosition();
int getHight = mListView.getHeight();
mListView.smoothScrollBy( ( ( getHight * position ) * -1 ), duration * 2 );
this.mListView.postDelayed( new Runnable() {
@Override
public void run() {
mListView.smoothScrollBy( 0, 0 );
mListView.setSelection( 0 );
}
}, duration );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment