scrollToPosition is not working
Achieved it via handler.
snappingRecyclerView.postDelayed(new Runnable() { @Override public void run() { snappingRecyclerView.scrollToPosition(centerItemPosition); } }, 500);
The distance is calculated wrong. I modified the scrollToPosition method. It works well.
@Override public void scrollToPosition(int position) { int scrollDistance = (position - getSelectedPosition()) * _childViewMetrics.size(getChildAt(0); smoothScrollBy(scrollDistance); }
scrollToPosition is not working. The error from debugger said "Attempt to invoke virtual method 'int android.view.View.getWidth()' on a null object reference"