What is AnimatedRecyclerView?

Animated RecyclerView is a library that allows you to animate a recycler view in your project like Google does it in its Google Play Store. Only the first visible items are animated there and you will see no animation when the recycler view scrolls up.

Reasons to Use It

This library solves several problems:

  1. It works stably fast and without jerks.
  2. It doesn’t need to utilize the adapter to animate items when they appear for the first time.

Why We Created AnimatedRecyclerView?

While working on a project, we needed to add an animation similar to the one used in the Google Play Store but didn’t find any appropriate library on Github that could help us with this task. We decided to create our own library to reuse it in other projects.

How We Did It

The standard implementation consists of two main animation types:

  • Item animation
  • Layout animation

Let’s go through all steps of implementation out of the box.

First of all, it’s necessary to define a file called item_animation_from_bottom.xml in res/anim/. This animation is used for each item of the RecyclerView.

Define an Item Animation
Define an Item Animation

The next step is to create a file layout_animation_from_bottom.xml in res/anim/ that uses the item animation from the code snippet above.

Create a Layout Animation
Create a Layout Animation

Finally it’s necessary to apply the created layout animation. There are two ways of doing it:

  • Programmatically

Programmatic Way of Applying a Layout Animation
Programmatic Way of Applying a Layout Animation

  • XML layout

Applying a Layout Animation via XML Layout
Applying a Layout Animation via XML Layout

Start animation

This is how we start the animation we’ve just created:

Start Animation in RecyclerView
Start Animation in RecyclerView

Looking to learn more about Animated RecyclerView?

Visit MLSDev profile on GitHub for more information about our library.

Our Way of Implementing Animations

We already defined some item/layout animations and you don’t need to go through the first two steps described above. In case you still want to define any other item/layout animation you can easily do it and use it with our AnimatedRecyclerView.

If the animations defined by us work for you, you can begin straight from applying a layout animation using one of the already mentioned ways:

  • From the code

Applying a Layout Animation From the Code
Applying a Layout Animation From the Code

  • From the XML layout

Applying a Layout Animation From the XML Layout
Applying a Layout Animation From the XML Layout

Start animation

Now you can start your animation:

Start Animation in Animated RecyclerView
Start Animation in Animated RecyclerView

Or your RecyclerView should extend the Animated RecyclerView and an adapter should be set:

Extend Animated RecyclerView with RecyclerView and Set Adapter
Extend Animated RecyclerView with RecyclerView and Set Adapter

Want to learn more about our Android development services?

Get in touch with us to discuss your Android project and learn how our team can assist you.

Contact us