List of usage examples for android.widget GridView smoothScrollToPosition
@android.view.RemotableViewMethod public void smoothScrollToPosition(int position)
From source file:Main.java
/** * smoothScroll a specific item to the center of the list :D * * @param position/* w w w. j ava 2 s .c o m*/ */ public static void smoothScrollToCenterPosition(GridView gridView, int position) { int pos = position; if (position <= gridView.getFirstVisiblePosition()) { pos = position - (gridView.getChildCount() / 2); if (pos < 0) { pos = 0; } gridView.smoothScrollToPosition(pos); } else { pos = position + (gridView.getChildCount() / 2); if (pos >= gridView.getCount()) { pos = gridView.getCount() - 1; if (pos < 0) { pos = 0; } } } gridView.smoothScrollToPosition(pos); }