Created
July 12, 2016 08:09
-
-
Save olkunmustafa/f619f6c8af423bf1ce13a9aafd76f3ba to your computer and use it in GitHub Desktop.
Used when it is wanted to set selection listview with animation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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