RecyclerView Elements Resize After Update

I have RecyclerViewas below:

Recyclerview

This is the installation code for this RecyclerView:

RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this, 2);
dataRecyclerView.setLayoutManager(layoutManager);
dataRecyclerView.addItemDecoration(new GridSpacingItemDecoration(...);
dataRecyclerView.setItemAnimator(new DefaultItemAnimator());

after starting a new action, when I update the selected RecyclerView element, the RecyclerView is re-populated with new data to reflect the new change, but I get the following result:

Result 1

And when I scroll down, I get this space:

Result 2

I tried to call RecyclerView#invalidate(), #invalidateItemDecorations(), #requestLayout()after the update, but to no avail; and I also do not call setHasFixedSize(true)on RecyclerView.

What is the problem? How to resize child elements so that they flow around their contents after the update?

(P.S: , , , .)

+4
1

, . , - .

, - recyclerview:

recyclerView.addItemDecoration(new SpacesItemDecoration(8));

, recyclerview recyclerview. , .

,

+1

All Articles