Learning Android Development

RecyclerView with Compose View is not Performant

Pick either RecyclerView or LazyColumn. Avoid mixing.

Photo by Alice Dietrich on Unsplash

As an experienced Android Developer, we know RecyclerView. But with Jetpack Compose, now we have LazyColumn.

But in the event, if we have an App that is actively being used, with lots of different ViewHolders in it’s RecyclerView, is it possible to add a Composable View as a ViewHolder?

The answer is YES!

How to add Composable View in View Holder?

The guide is provided in Android Documentation. I’ll show you a simple design as below.

To design a ReyclerView, it’s easier to start from the ViewHolder first, then go backward, as advocated by this article.

1. Designing the ViewHolder with ComposeView

class ComposeItemViewHolder(
val composeView: ComposeView
) : RecyclerView.ViewHolder(composeView) {…

--

--