Akshat Singhal
Akshat Singhal

Reputation: 19

Is it good practice to use ViewPager2 with a single fragment in a vertical RecyclerView layout?

Is it a good practice to use ViewPager2 with a single fragment for just one item in the RecyclerView, while other items are normal views? Are there any performance or architectural concerns with this approach, or is there a better way to handle state management for Compose with ViewModel in a RecyclerView layout like this?

I’m building an Android app with a vertical RecyclerView inside a fragment. Most of the items in the RecyclerView are normal Android views, such as ImageView and rows of tile icons. However, one item in the list contains a ViewPager2.

I’m using Jetpack Compose with a ViewModel to manage the Compose UI state, and I want to ensure the Compose state is isolated and maintained properly. To achieve this, I plan to use a separate fragment for the ViewPager2 item, while other items remain as normal Android views.

Any suggestions or best practices would be greatly appreciated!

Upvotes: -1

Views: 48

Answers (0)

Related Questions