diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2012-06-18 08:53:18 -0700 |
---|---|---|
committer | android code review <noreply-gerritcodereview@google.com> | 2012-06-18 08:53:18 -0700 |
commit | 20d6caf8888d4114b6ce79d93c7c9cf903ad8c22 (patch) | |
tree | ebe3e0949b50622633467b228527dd518a0ef875 | |
parent | 0cf342184e030ee6f65d87eeba48484725910a8b (diff) | |
parent | bbf7b4cdcfbc5aa436500dad96e73f7a3b32e794 (diff) | |
download | frameworks_base-20d6caf8888d4114b6ce79d93c7c9cf903ad8c22.zip frameworks_base-20d6caf8888d4114b6ce79d93c7c9cf903ad8c22.tar.gz frameworks_base-20d6caf8888d4114b6ce79d93c7c9cf903ad8c22.tar.bz2 |
Merge "Fix issue #13366. Take account of stackFromBottom in computeVerticalScrollOffset()."
-rw-r--r-- | core/java/android/widget/GridView.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/widget/GridView.java b/core/java/android/widget/GridView.java index 5d406de..428af83 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); } |