Android Recyclerview Layoutmanager onLayoutChildren is called when item content changes

I have a recycler view with a custom layout manager (its twowayview staggeredgridview layout manager https://github.com/lucasr/twoway-view/blob/master/layouts/src/main/java/org/lucasr/twowayview/widget/StaggeanredGridLayoutMager .java )

I am using this to display a list of images. These images are loaded asynchronously, that is, when the items become active, I decode the image data and then load this bitmap into these views of the list items.

now the problem is that when I set the bitmap of the image to the image of the image it calls onLayoutChildren to be called in the layout manager which then throws out all the children again.

Is this the expected behavior? value changing the content of the child (here, the image) causes the parent recyclerview to issue onLayoutChildren to its layout manager?

If not, how can you prevent it?

Thank,

+3


source to share


1 answer


Yes, that's how the layout system works. If a child asks for a layout, all of its parent names will be called.



If your view doesn't resize when a new bitmap arrives, you can handle it by writing a custom view that expands your view and prevents calls requestLayout

. Search eatRequestLayout

the source code for RecyclerView for an idea of ​​how to do this.

+5


source







All Articles