[x] I have searched existing issues and confirmed this is not a duplicate
Issues and steps to reproduce
I use FlexboxLayoutManager with RecyclerView.Adapter to show short texts of roughly 4x20 on the screen at any time. To isolate the issue from data loading, I tested with a static set of items about 1000 loaded. As I scroll down, new items are shown from below and older items go out from the top. When I scroll fast, the views become very sluggish and jittery with abrupt stops in between. Interestingly, the sluggishness only seems to happen when I scroll down (scrolling up appears much better), even scrolling down again after having scrolled back up.
As I browsed through the code, without fully comprehending it, I found something I can't explain. In FlexboxLayoutManager.java, view cache is cleared while scrolling:
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
RecyclerView.State state) {
if (isMainAxisDirectionHorizontal() ||
(mFlexWrap == FlexWrap.NOWRAP && !isMainAxisDirectionHorizontal())) {
int scrolled = handleScrollingMainOrientation(dy, recycler, state);
mViewCache.clear();
return scrolled;
} else {
int scrolled = handleScrollingSubOrientation(dy);
mAnchorInfo.mPerpendicularCoordinate += scrolled;
mSubOrientationHelper.offsetChildren(-scrolled);
return scrolled;
}
}
I commented out the line mViewCache.clear(); in my local copy, then things appear drastically improved for me, at least scrolling down again becomes very smooth, though I don't know yet if it would cause other problems.
Issues and steps to reproduce
I use FlexboxLayoutManager with RecyclerView.Adapter to show short texts of roughly 4x20 on the screen at any time. To isolate the issue from data loading, I tested with a static set of items about 1000 loaded. As I scroll down, new items are shown from below and older items go out from the top. When I scroll fast, the views become very sluggish and jittery with abrupt stops in between. Interestingly, the sluggishness only seems to happen when I scroll down (scrolling up appears much better), even scrolling down again after having scrolled back up.
I have a RecyclerView within a LinearLayout, as
Each item for the RecyclerView is defined as:
In Java code,
Expected behavior
I expect to see smoother scrolling
As I browsed through the code, without fully comprehending it, I found something I can't explain. In FlexboxLayoutManager.java, view cache is cleared while scrolling:
I commented out the line
mViewCache.clear();
in my local copy, then things appear drastically improved for me, at least scrolling down again becomes very smooth, though I don't know yet if it would cause other problems.Version of the flexbox library
3.0.0