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?
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.
It goes into the
else if
block and resets position.Also while calculating
mVisibleColumnCount
andmVisibleRowCount
you add 1, any particular reason for that?mVisibleColumnCount = (getHorizontalSpace() / mDecoratedChildWidth) + 1;
mVisibleRowCount = (getVerticalSpace()/ mDecoratedChildHeight) + 1;