Created
September 15, 2018 11:37
-
-
Save imandaliya/c55950d89a43fdcc93ed5b6edc9fd7f1 to your computer and use it in GitHub Desktop.
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
// Smooth scroll grid view item to center using | |
private void smoothScrollToCenter(GridView gridView, View child) { | |
Rect rect = new Rect(); | |
gridView.getGlobalVisibleRect(rect); | |
gridView.smoothScrollBy(child.getBottom() - gridView.getScrollY() - rect.centerY() + child.getHeight() / 2, 200); | |
} | |
// now call in setOnItemClickListener method | |
smoothScrollToCenter(gridViewColor, view); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment