am 20d6caf8: Merge "Fix issue #13366. Take account of stackFromBottom in computeVerticalScrollOffset()."
* commit '20d6caf8888d4114b6ce79d93c7c9cf903ad8c22': Fix issue #13366. Take account of stackFromBottom in computeVerticalScrollOffset().
This commit is contained in:
committed by
Android Git Automerger
commit
98e955d295
@@ -2207,8 +2207,13 @@ public class GridView extends AbsListView {
|
|||||||
int height = view.getHeight();
|
int height = view.getHeight();
|
||||||
if (height > 0) {
|
if (height > 0) {
|
||||||
final int numColumns = mNumColumns;
|
final int numColumns = mNumColumns;
|
||||||
final int whichRow = mFirstPosition / numColumns;
|
|
||||||
final int rowCount = (mItemCount + numColumns - 1) / 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 +
|
return Math.max(whichRow * 100 - (top * 100) / height +
|
||||||
(int) ((float) mScrollY / getHeight() * rowCount * 100), 0);
|
(int) ((float) mScrollY / getHeight() * rowCount * 100), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user