Skip to content
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

FixedTwoWayFragment snaps to origin on item click and view manipulation #26

Open
manishkumar opened this issue Jul 27, 2016 · 0 comments

Comments

@manishkumar
Copy link

In case of just one extra element (invisible) in a row and manipulating sub views on click causes it to snap to the first element. Here is the video showing it and here is the source code that is used the video

I hide one the row item sub views(home score textview). If I do not hide the textview and only change its value it works fine. Also if there are more than one (1) elements off the screen it works fine.

I went through the source code of FixedGridLayoutManager and it turns out this code is responsible for snapping.

if (getChildCount() == 0) { //First or empty layout
    //Reset the visible and scroll positions
    mFirstVisiblePosition = 0;
    childLeft = getPaddingLeft();
    childTop = getPaddingTop();
} else if (!state.isPreLayout()
        && getVisibleChildCount() >= state.getItemCount()) {
    //Data set is too small to scroll fully, just reset position
    mFirstVisiblePosition = 0;
    childLeft = getPaddingLeft();
    childTop = getPaddingTop();
} 

It goes into the else if block and resets position.

Also while calculating mVisibleColumnCount and mVisibleRowCount you add 1, any particular reason for that?

mVisibleColumnCount = (getHorizontalSpace() / mDecoratedChildWidth) + 1;
mVisibleRowCount = (getVerticalSpace()/ mDecoratedChildHeight) + 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant