Shimmer Effect to Image in Android
Last Updated :
23 Feb, 2021
Shimmer Effect is one of the most popular features that we see in most Android apps. We can get to see this Shimmer Effect while loading the screen in animated form. Using Shimmer Effect in the Android app makes a good User Experience. In this article, we are going to see how to implement the Shimmer Effect in the Android app. A sample GIF is given below to get an idea about what we are going to do in this article. Note that we are going to implement this project using the Java language.

Applications of Shimmer Effect
- Shimmer Effect is mostly used for loading the screen in an attractive form.
- Shimmer Effect gives a good appearance to Images in the Android app.
- Using Shimmer Effect in our app gives an Animated view of the image.
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. Note that select Java as the programming language.
Step 2: Add dependency of Shimmer Effect library in build.gradle file
Then Navigate to gradle scripts and then to build.gradle(Module) level. Add below line in build.gradle file in the dependencies section.
implementation 'com.facebook.shimmer:shimmer:0.5.0'
now click on Sync now it will sync your all files in build.gradle().
Step 3: Create a new Shimmer Effect in your 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.
XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp"
tools:context=".MainActivity">
<!--Shimmer Effect-->
<com.facebook.shimmer.ShimmerFrameLayout
android:id="@+id/shimmer_view_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<!--Image-->
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/ic_baseline_account_balance_24" />
<!--Text given to Image-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:text="Bank"
android:textColor="@color/purple_200"
android:textSize="24dp"
android:textStyle="bold" />
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
<!--Button1 to start Shimmer Effect-->
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:paddingLeft="20dp"
android:text="Start" />
<!--Button2 to stop Shimmer Effect-->
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:paddingRight="20dp"
android:text="Stop" />
</RelativeLayout>
Step 4: Working with the MainActivity.java file
Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail.
Java
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
import com.facebook.shimmer.ShimmerFrameLayout;
public class MainActivity extends AppCompatActivity {
// Variables created for buttons and Shimmer
Button button1, button2;
ShimmerFrameLayout container;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = findViewById(R.id.button);
button2 = findViewById(R.id.button2);
// Button 1 to start Shimmer Effect
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// If auto-start is set to false
container.startShimmer();
}
});
// Button 2 to stop Shimmer Effect
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// If auto-start is set to false
container.stopShimmer();
}
});
// Shimmer effect
container = (ShimmerFrameLayout) findViewById(R.id.shimmer_view_container);
}
}
Now click on the run option it will take some time to build Gradle. After that, you will get output on your device as given below.
Output:
Similar Reads
Android Architecture Android architecture contains a different number of components to support any Android device's needs. Android software contains an open-source Linux Kernel having a collection of a number of C/C++ libraries which are exposed through application framework services. Among all the components Linux Kern
5 min read
Types of Functional dependencies in DBMS In relational database management, functional dependency is a concept that specifies the relationship between two sets of attributes where one attribute determines the value of another attribute. It is denoted as X â Y, where the attribute set on the left side of the arrow, X is called Determinant,
6 min read
Understanding TF-IDF (Term Frequency-Inverse Document Frequency) TF-IDF (Term Frequency-Inverse Document Frequency) is a statistical measure used in natural language processing and information retrieval to evaluate the importance of a word in a document relative to a collection of documents (corpus). Unlike simple word frequency, TF-IDF balances common and rare w
6 min read
List Comprehension in Python List comprehension is a way to create lists using a concise syntax. It allows us to generate a new list by applying an expression to each item in an existing iterable (such as a list or range). This helps us to write cleaner, more readable code compared to traditional looping techniques.For example,
4 min read
Android Tutorial In this Android Tutorial, we cover both basic and advanced concepts. So whether you are a fresher (graduate) or an experienced candidate with several years of Android Development experience, you can follow this Android tutorial to kick-start your journey in Android app development. Our Android Tutor
15+ min read
Mean, Median and Mode Mean, Median, and Mode are measures of the central tendency. These values are used to define the various parameters of the given data set. The measure of central tendency (Mean, Median, and Mode) gives useful insights about the data studied, these are used to study any type of data such as the avera
15+ min read
Stock Buy and Sell - Max one Transaction Allowed Given an array prices[] of length N, representing the prices of the stocks on different days, the task is to find the maximum profit possible by buying and selling the stocks on different days when at most one transaction is allowed. Here one transaction means 1 buy + 1 Sell.Note: Stock must be boug
8 min read
30 Days of SQL - From Basic to Advanced Level This basic to advanced SQL tutorial covers the entire SQL syllabus in a structured way and provides the best learning material and strategies to master complete SQL in 30 Days. We have laid out the complete SQL roadmap, and following this roadmap, you will learn all the concepts of SQL. All Importan
8 min read
Data Scientist Roadmap - A Complete Guide [2025] Welcome to your comprehensive Data Science Roadmap! If youâve ever wondered, about âSteps or Path to Become a Data Scientistâ, youâre in the right place. This guide is perfect for Data Science for Beginners and seasoned professionals alike, covering everything from mastering Python for Data Science
8 min read
What is An Event Loop in JavaScript? The event loop is an important concept in JavaScript that enables asynchronous programming by handling tasks efficiently. Since JavaScript is single-threaded, it uses the event loop to manage the execution of multiple tasks without blocking the main thread.JavaScriptconsole.log("Start"); setTimeout(
4 min read