Lazy Column/Row recomposition and perfomance

Viewed 151

I have the following structure in the LazyColumn:

item {
  // complex layout with long time of recomposition and inside the HorizontalPager
}
items(list) {
  // item content
}

The issue is when I scroll down until the first item becomes invisible and scroll back, every time the first item appears on the screen it freezes.

I know that lazy layouts recompose their items unlike the RecyclerView which just binds data to a ViewHolder. But in this case the lazy layout works awful. Recomposing my first item takes too much time to provide a smooth scroll to the top.

Also I've mentioned in the structure that my complex layout is inside the HorizontalPager, which is a lazy layout too. Swiping this pager is not smooth either.

How to handle this? Is there a way to cache or prevent recomposition in a lazy layout? Something like RecyclerView binding?

0 Answers
Related