diff options
| author | Jean-Baptiste Queru <jbq@google.com> | 2012-06-18 09:27:53 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-18 09:27:53 -0700 |
| commit | fce51d58739f05c9c4729a2d574024bea8bc8e91 (patch) | |
| tree | 2fabc4e4f03ef74025d7de0f42c7b66c6302ee4b /core/java/android/widget/GridView.java | |
| parent | 81f58c2083b1bc29647fb729bd2c885435a64bf0 (diff) | |
| parent | 98e955d295441636ba19688e18a8223691256d2c (diff) | |
am 98e955d2: am 20d6caf8: Merge "Fix issue #13366. Take account of stackFromBottom in computeVerticalScrollOffset()."
* commit '98e955d295441636ba19688e18a8223691256d2c':
Fix issue #13366. Take account of stackFromBottom in computeVerticalScrollOffset().
Diffstat (limited to 'core/java/android/widget/GridView.java')
| -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 71ad148591a1..f23e1aaaf47a 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -2217,8 +2217,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); } |
