diff options
| author | Jean-Baptiste Queru <jbq@google.com> | 2012-06-18 09:23:55 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2012-06-18 09:23:55 -0700 |
| commit | 98e955d295441636ba19688e18a8223691256d2c (patch) | |
| tree | 3215519561c2401feeae9e59d0f2ef27c39227dc /core/java/android/widget/GridView.java | |
| parent | 535d3b3f3363af6a5f2acb620542baec4cb96b45 (diff) | |
| parent | 20d6caf8888d4114b6ce79d93c7c9cf903ad8c22 (diff) | |
am 20d6caf8: Merge "Fix issue #13366. Take account of stackFromBottom in computeVerticalScrollOffset()."
* commit '20d6caf8888d4114b6ce79d93c7c9cf903ad8c22':
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 897510940721..ada7dd1dd1c9 100644 --- a/core/java/android/widget/GridView.java +++ b/core/java/android/widget/GridView.java @@ -2207,8 +2207,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); } |
