diff --git a/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java b/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java index 21bd2d53..ad51c367 100644 --- a/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java +++ b/flexbox/src/main/java/com/google/android/flexbox/FlexboxLayoutManager.java @@ -2242,7 +2242,7 @@ private int computeScrollOffset(RecyclerView.State state) { int maxPosition = getPosition(lastReferenceView); int laidOutArea = Math.abs(mOrientationHelper.getDecoratedEnd(lastReferenceView) - mOrientationHelper.getDecoratedStart(firstReferenceView)); - int firstLinePosition = mFlexboxHelper.mIndexToFlexLine[minPosition]; + int firstLinePosition = minPosition != NO_POSITION ? mFlexboxHelper.mIndexToFlexLine[minPosition] : 0; if (firstLinePosition == 0 || firstLinePosition == NO_POSITION) { return 0; }