Jul 10, 2017 · 1 min read
Two things are really wrong with your solution:
- Don’t create a custom RecyclerView. This forces the developers to change their layouts and prevents them from using your library in combination with other custom RecyclerViews. Contrary to ListView, RecyclerView is designed to be modular so you can easily register a custom
LayoutManagerand one or moreItemDecoration,OnScrollListener, and more. If your solution needs more than one of these classes, you can create a standalone component which works similarly toSnapHelperand registers all classes in a singleattachToRecyclerView()method. - To resize items, you are changing LayoutParams of visible views on each frame which is really bad for performance and should be strictly avoided. I would rather recommend that you offset the view positions and play with clipping to cover their top or bottom parts. You can also cross-fade cells between an expanded and a collapsed state.
