RecyclerView jumps when scrolling variable height ComposeView items

Viewed 148

I have a RecyclerView that's hosting items rendered with Jetpack Compose. The height of the items varies. When scrolling from the top of the list to the bottom, scrolling is smooth. However, when scrolling back to the top, the items in the list jump when the height of the next item to appear at the top of the screen differs from the height of the item that was previously at the top of the screen.

The layout height of each ComposeView is set to WRAP_CONTENT. The previous XML layouts scrolled smoothly in both directions.

I am using Compose 1.2.0 and RecyclerView 1.3.0-beta01.

Is there a solution for having smooth scrolling in both directions?

Update: I have reported a bug here and provided a sample project demonstrating the problem here.

1 Answers

A little late but which version of Compose are you using?

I came across this in version 1.2.0-alpha06 release notes:

"Upgrading both RecyclerView and Compose will now result in much better scrolling performance for RecyclerViews with Compose views as children."

Maybe you need to update to the latest (1.2.0-alpha06 was released in March 2022)...

Related