As per https://developer.android.com/jetpack/compose/interop/compose-in-existing-ui#compose-recyclerview, the composable ViewHolder that can be used in RecyclerView is as below
import androidx.compose.ui.platform.ViewCompositionStrategy
class MyComposeViewHolder(
val composeView: ComposeView
) : RecyclerView.ViewHolder(composeView) {
init {
composeView.setViewCompositionStrategy(
ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed
)
}
fun bind(input: String) {
composeView.setContent {
MdcTheme {
Text(input)
}
}
}
}
It looks like, every time it is bind the composable setContent (i.e. redraw again).
I measure the speed using Profile GPU Rendering, it clearly show that the Hybrid of ReyclerView+ComposeViewHolder is slower than pure RecyclerView or LazyColumn.

You can get the design here
How can we speed up the Hybrid RecyclerView+ComposeViewHolder?
The latest version of RecyclerView (1.3.0-alpha02) and Compose (1.2.0-beta02) have improved support and performance for Compose when used in RecyclerView thanks to the PoolingContainer library it uses. No need to dispose nor set the ViewCompositionStrategy. Note that the content in https://developer.android.com/jetpack/compose/interop/compose-in-existing-ui#compose-recyclerview is only needed if you are using stable versions of the libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With