I found part of the logic in AbsListView, which I've pasted below. Note that the vertical scroll offset is calculated based on the assumption that all the child Views will have the same height. In my case the child Views are all different heights but I do have an array that contains a list of those heights so it's easy to modify the math to calculate the correct scroll offset for my case.
I'd like to modify the AbsListView class with two new protected methods which can be overridden to allow proper behavior in my case. The first would be boolean allChildViewsSameHeight(), which would return true in the default case. The second would be int getHeightOfChildAt( int childIndex ), which would return the height of the first child as a default and could be overridden to return different heights. In addition, I'd like to modify the math below to use getHeightOfChildAt in the case where allChildViewsSameHeight returns false. What is the method to merge this change back into the main source tree once I have tested it? @Override protected int computeVerticalScrollOffset() { final int firstPosition = mFirstPosition; final int childCount = getChildCount(); if (firstPosition >= 0 && childCount > 0) { if (mSmoothScrollbarEnabled) { final View view = getChildAt(0); final int top = view.getTop(); int height = view.getHeight(); if (height > 0) { return Math.max(firstPosition * 100 - (top * 100) / height + (int)((float)mScrollY / getHeight() * mItemCount * 100), 0); } } else { int index; final int count = mItemCount; if (firstPosition == 0) { index = 0; } else if (firstPosition + childCount == count) { index = count; } else { index = firstPosition + childCount / 2; } return (int) (firstPosition + childCount * (index / (float) count)); } } return 0; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en