Animations and Performance in Nested RecyclerViews

This page summarizes the projects mentioned and recommended in the original post on /r/RedditEng

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • flexbox-layout

    Flexbox for Android

  • In order to properly encapsulate the reaction view logic, we created a class that extends RecyclerView and has a bind method that takes in the list of reactions and updates the RecyclerView’s adapter with that list. Given that we had to support a multi-line layout, we initially looked into using GridLayoutManager to achieve this but ended up finding an open-source library by Google named flexbox-layout that provides a LayoutManager that supports laying out items in multiple flex-rows, which is exactly what we needed. Using these ingredients, we were able to get a simple version of our layout up and running. What’s next was adding custom animations and improving performance.

  • recyclerview-animators

    An Android Animation library which easily add itemanimator to RecyclerView items.

  • Next, we looked at overriding SimpleItemAnimator but noticed that this class is missing a lot of logic required for orchestrating the animations. We realized that the Android SDK does not really allow us to easily customize RecyclerView item animations - what a shame! Doing some research on this we found two open-source libraries (here and here - note: this is no endorsement) that provide a variety of custom ItemAnimators by using a base ItemAnimator implementation that is very similar to the DefaultItemAnimator class but allows for proper customization. We ended up creating our own BaseItemAnimator by looking at DefaultItemAnimator and adapting it to our needs and then creating the actual implementation for the reaction feature. This allowed us to customize the “Add” animation like so:

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • ItemAnimators

    ItemAnimators: Supercharged Animators for your RecyclerView

  • Next, we looked at overriding SimpleItemAnimator but noticed that this class is missing a lot of logic required for orchestrating the animations. We realized that the Android SDK does not really allow us to easily customize RecyclerView item animations - what a shame! Doing some research on this we found two open-source libraries (here and here - note: this is no endorsement) that provide a variety of custom ItemAnimators by using a base ItemAnimator implementation that is very similar to the DefaultItemAnimator class but allows for proper customization. We ended up creating our own BaseItemAnimator by looking at DefaultItemAnimator and adapting it to our needs and then creating the actual implementation for the reaction feature. This allowed us to customize the “Add” animation like so:

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts