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?
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
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.
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