From bbf7b4cdcfbc5aa436500dad96e73f7a3b32e794 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Vandormael Date: Sat, 16 Jun 2012 17:11:54 +0200 Subject: Fix issue #13366. Take account of stackFromBottom in computeVerticalScrollOffset(). Change-Id: I743708ef1ac05e358840f37010de36b7d0c6a346 Signed-off-by: Pieter-Jan Vandormael --- core/java/android/widget/GridView.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/java/android/widget/GridView.java') diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 5d406de007dc..428af836097e 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -2095,8 +2095,13 @@ public class GridView extends AbsListView { int height = view.getHeight(); if (height > 0) { final int numColumns = mNumColumns; - final int whichRow = mFirstPosition / numColumns; final int rowCount = (mItemCount + numColumns - 1) / numColumns; + // In case of stackFromBottom the calculation of whichRow needs + // to take into account that counting from the top the first row + // might not be entirely filled. + final int oddItemsOnFirstRow = isStackFromBottom() ? ((rowCount * numColumns) - + mItemCount) : 0; + final int whichRow = (mFirstPosition + oddItemsOnFirstRow) / numColumns; return Math.max(whichRow * 100 - (top * 100) / height + (int) ((float) mScrollY / getHeight() * rowCount * 100), 0); } -- cgit v1.2.3