Some elements are not seen in the nested recyclerview after doing smooth scroll to position 0

257 Views Asked by At

I have a recyclerview inside another recycler view, but when I apply the method to the parent to go to a certain child, some recyclerview of those children are not seen, but the rest of the child is seen. The internal recyclerview is as follows.

                val layout = GridLayoutManager(itemView.context, 2)
                layout.recycleChildrenOnDetach = true
                layoutManager = layout

                val mAdapter = Adapter(onChildItemClick)

                adapter = mAdapter
                mAdapter.oldList = datesModelObject.list

                isNestedScrollingEnabled = false
                setHasFixedSize(true)

                
             setRecycledViewPool(RecyclerView.RecycledViewPool())
2

There are 2 best solutions below

0
Chuy Porras On BEST ANSWER

I just removed

layout.recycleChildrenOnDetach = true

and work perfectly

0
Roman Chekashov On

From official docs:

Recycled view pools allow multiple RecyclerViews to share a common pool of scrap views. This can be useful if you have multiple RecyclerViews with adapters that use the same view types, for example if you have several data sets with the same kinds of item views displayed by a ViewPager.

By default, 5 ViewHolders are retained in the pool for a particular viewType. If you want to change that count, it may be done this way:

recyclerView.getRecycledViewPool()
            .setMaxRecycledViews(SOME_VIEW_TYPE, POOL_CAPACITY);