VOOZH about

URL: https://www.geeksforgeeks.org/android/how-to-add-fade-and-shrink-animation-in-recyclerview-in-android/

⇱ How to Add Fade and Shrink Animation in RecyclerView in Android? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Add Fade and Shrink Animation in RecyclerView in Android?

Last Updated : 23 Jul, 2025

In this article, we are going to show the fade and shrink animation in RecyclerView. When we move downward then the item at the top will be fading out and then it will shrink. In the output, we can see how it is happening.

We will be implementing Java/Kotlin programming language.

Step by Step Implementation

Step 1: Create a new Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

Step 2: Create a Custom Layout Manager

Navigate to app > java > {package-name}, right click and select New > Java/Kotlin Class and set the name as CustomLayoutManager.

Now add the following code to the file.


Step 3: Create a Custom Snap Helper for the Layout Manager

Navigate to app > java > {package-name}, right click and select New > Java/Kotlin Class and set the name as StartSnapHelper.

Now add the following code to the file.


Step 4: Working with the item.xml file

Go to the app > res > layout > New > Layout Resource File and name the file as item. Go to the item.xml file and refer to the following code. Below is the code for the item.xml file.

item.xml:


Step 4: Working with the Adapter file

Create a new Java/Kotlin class and name the class as Adapter. Go to the Adapter file and refer to the following code.


Step 5: Working with the activity_main.xml file

Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file. 

activity_main.xml:


Step 6: Working with the MainActivity file

Go to the MainActivity file and refer to the following code. Below is the code for the MainActivity file. Comments are added inside the code to understand the code in more detail.


Output:


Comment
Article Tags:

Explore