Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a Good Idea to make everything recyclerview?

Is it a good idea to make everything a RecyclerView in Android?

If you think about it, all scrolling UI could be composed with a RecyclerView with multiple viewTypes.

Is that a good or a bad thing to do?

like image 669
Archie G. Quiñones Avatar asked Jan 27 '23 07:01

Archie G. Quiñones


2 Answers

Here is my opinion.
Apply RecyclerView with multiple take more code than ScrollView. If apply RecyclerView don't make any thing better (eg: performance) then I will not use RecyclerView

So I only apply RecyclerView when
- I have a long list (at least the number of list should > 6, because after debug I see RecyclerView default create and keep 6 views)
- Item in RecyclerView can reuse, example I have a list with 10 item but 10 item is completely different (eg: each item is a type) -> I will not use RecyclerView
- Sometime, I apply RecyclerView for the list which can expand in future. Example, I have a setting screen with setting option item, I apply RecyclerView here because I want to add new option item easier

like image 85
Linh Avatar answered Feb 04 '23 16:02

Linh


There's a library called Epoxy by Airbnb that does exactly this. So clearly at least some people think it's a good idea.

Personally, I think that most UIs are easy enough to represent with just a ScrollView and some static views, and therefore the (admittedly not-huge) overhead of Epoxy isn't worth it. But it's certainly not a crazy idea. And if your layout is getting complex, then the overhead becomes less and less in relation to your overall codebase and so it could be worth it.

At the very least, this is one good way to avoid having to manually set up RecyclerViews that use multiple view types.

like image 30
Ben P. Avatar answered Feb 04 '23 17:02

Ben P.