Is there any way in RecyclerView to keep items in memory like the setOffscreenPageLimit() function in ViewPager?

Asked 1 years ago, Updated 1 years ago, 124 views

I'm making an app for securities, and I'm drawing a line graph by holding the items of RecyclerView with a candle.

If you scroll through this graph, the items in RecyclerView will be erased, and the values to continue the line graph will disappear.

The video file cannot be uploaded.

In the section where the item disappears ( | ) while the line graph continues to scroll, the x-coordinate of the item disappears because it cannot be obtained.

Is there a method like the setOffscreenPageLimit(int) function of ViewPager that forces the item to be loaded in RecyclerView?

Or is there another solution?

recyclerview android-viewpager setoffscreenpagelimit

2022-09-22 21:16

1 Answers

RecyclerView is designed to cache View internally. The cache size can be adjusted using the setItemViewCacheSize() function (the default cache size is 2) You can control the view from being recycled by adjusting the cache size. However, I've never controlled this myself, so I'm not sure if it's a good way.

This article summarizes the internal movements of RecyclerView, so it would be helpful to refer to it.


2022-09-22 21:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.