-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HorizontalListView: scrollTo last items #24
Comments
Current mMaxX forumla is mMaxX = mCurrentX + rightEdge - getWidth(); But rightEdge can be 0 after all the items removed in removeNonVisibleMethods which gives inaccuracy in calc Scenario is like this mCurrentX is 0 Next requested scroll to 10000 |
Fix proposal. Modify fillList method and use default edge value as mDisplayOffset instead of 0. Currently testing such solution so not sure how proper it is. int edge = mDisplayOffset;
View child = getChildAt(getChildCount() - 1);
if (child != null) {
edge = child.getRight();
}
fillListRight(edge, dx); |
I'm getting a similar issue, but this fix does not work on my case. On a 1280px screen I'm drawing 6 items with width 220. Any suggestions on this? |
@Dq do you use scrollTo method? |
@Dq also do you have padding specified on the root layout container for your items? |
@httpdispatch yes, the scrollTo method is being called when I swipe on the list. |
I think this is because of padding. It is used wrongly for offset calculation in one place. |
private void positionItems(final int dx) {
if(getChildCount() > 0){
mDisplayOffset += dx;
int left = mDisplayOffset;
for(int i=0;i<getChildCount();i++){
View child = getChildAt(i);
int childWidth = child.getMeasuredWidth();
child.layout(left, 0, left + childWidth, child.getMeasuredHeight());
left += childWidth + child.getPaddingRight();
}
}
} child.getPaddingRight() seems incorrect here try to remove padding attribute from the items root and add pading to child |
<root layout>
<child layout padding=15/>
</root layout> |
Assuming is the HorizontalListView, then the items I have inside of it (LinearLayouts) are the ones with the padding. So I think what you're telling me to try is the way it is already (not) working. |
HorizontalListView childs root should not have padding. So if you have layout for child item LinearLayout with padding 15 move that padding from root to child <LinearLayout padding = 15>
<ChildView/>
</LinearLayout> after <LinearLayout>
<ChildView padding = 15/>
</LinearLayout> |
OK, so that was indeed the issue. |
I'm getting an issue too with the scrollTo method, but I make no use of paddings. |
If i use scrollTo to the one of the last item mMaxX is not calculated properly. This causes problem in scrolling to right (it can't be fully scrolled)
The text was updated successfully, but these errors were encountered: