Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
Pulse Animation View in Android
Next article icon

Pulse Animation View in Android

Last Updated : 18 Jan, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we are going to see the Pulse Animation feature. This feature can be used if we are downloading something from the server. Then till the time, it is downloading we can add this feature. 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.

Pulse Animation View in Android Sample GIF

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

Navigate to the Gradle Scripts > build.gradle(Module:app) and add the below dependency in the dependencies section.   

implementation 'pl.bclogic:pulsator4droid:1.0.3'

Step 3: Working with the activity_main.xml file

These are the following properties for changing layout parameter

  • pulse_count: Represents the Number of pulse circles
  • pulse_duration: Represents the Duration in milliseconds of single pulse
  • pulse_repeat: Represents the Number of pulse repeats. Zero means INFINITE
  • pulse_color: Represents the ARGB pulse colors
  • pulse_startFromScratch: Set to true if the animation should start from the beginning
  • pulse_interpolator: Set interpolator type used for animation. Accepted values are "Linear", "Accelerate", "Decelerate", "AccelerateDecelerate"

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:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:layout_gravity="center"     android:gravity="center"     android:orientation="vertical"     android:padding="16sp"     tools:context=".MainActivity">      <pl.bclogic.pulsator4droid.library.PulsatorLayout         android:id="@+id/pulsator"         android:layout_width="326dp"         android:layout_height="446dp"         android:layout_alignParentTop="true"         android:layout_centerHorizontal="true"         android:layout_marginTop="89dp"         app:pulse_color="#CA3D3D"         app:pulse_count="1"         app:pulse_duration="1800"         app:pulse_interpolator="Linear"         app:pulse_repeat="0"         app:pulse_startFromScratch="false">          <ImageView             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_centerInParent="true"             android:src="@mipmap/ic_launcher_round" />     </pl.bclogic.pulsator4droid.library.PulsatorLayout>      <LinearLayout         android:id="@+id/kl"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_below="@id/pulsator"         android:orientation="horizontal">          <TextView             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="Count" />          <SeekBar             android:id="@+id/count"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:max="4"             android:min="1" />     </LinearLayout>      <LinearLayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_below="@+id/kl"         android:orientation="horizontal">          <TextView             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:text="Duration" />          <SeekBar             android:id="@+id/duration"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_below="@id/count"             android:max="7"             android:min="1" />     </LinearLayout>      </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.widget.SeekBar;  import androidx.appcompat.app.AppCompatActivity;  import pl.bclogic.pulsator4droid.library.PulsatorLayout;  public class MainActivity extends AppCompatActivity {      SeekBar count, duration;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);                  // initialise the layout         PulsatorLayout pulsator = (PulsatorLayout) findViewById(R.id.pulsator);         pulsator.start();         count = findViewById(R.id.count);         duration = findViewById(R.id.duration);                  // on change in seekbar value         count.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {             @Override             public void onProgressChanged(SeekBar seekBar, int i, boolean b) {                 // change the count                 pulsator.setCount(i);             }              @Override             public void onStartTrackingTouch(SeekBar seekBar) {              }              @Override             public void onStopTrackingTouch(SeekBar seekBar) {              }         });                  // on change in seekbar value         duration.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {             @Override             public void onProgressChanged(SeekBar seekBar, int i, boolean b) {                 // change the duration                 pulsator.setDuration(i);             }              @Override             public void onStartTrackingTouch(SeekBar seekBar) {              }              @Override             public void onStopTrackingTouch(SeekBar seekBar) {              }         });     }      @Override     protected void onStart() {         super.onStart();      } } 
Java
import android.os.Bundle; import android.widget.SeekBar;  import androidx.appcompat.app.AppCompatActivity;  import pl.bclogic.pulsator4droid.library.PulsatorLayout;  public class MainActivity extends AppCompatActivity {      SeekBar count, duration;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);                  // initialise the layout         PulsatorLayout pulsator = (PulsatorLayout) findViewById(R.id.pulsator);         pulsator.start();         count = findViewById(R.id.count);         duration = findViewById(R.id.duration);                  // on change in seekbar value         count.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {             @Override             public void onProgressChanged(SeekBar seekBar, int i, boolean b) {                 // change the count                 pulsator.setCount(i);             }              @Override             public void onStartTrackingTouch(SeekBar seekBar) {              }              @Override             public void onStopTrackingTouch(SeekBar seekBar) {              }         });                  // on change in seekbar value         duration.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {             @Override             public void onProgressChanged(SeekBar seekBar, int i, boolean b) {                 // change the duration                 pulsator.setDuration(i);             }              @Override             public void onStartTrackingTouch(SeekBar seekBar) {              }              @Override             public void onStopTrackingTouch(SeekBar seekBar) {              }         });     }      @Override     protected void onStart() {         super.onStart();      } } 

Output: 

Java
import android.os.Bundle; import android.widget.SeekBar;  import androidx.appcompat.app.AppCompatActivity;  import pl.bclogic.pulsator4droid.library.PulsatorLayout;  public class MainActivity extends AppCompatActivity {      SeekBar count, duration;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);                  // initialise the layout         PulsatorLayout pulsator = (PulsatorLayout) findViewById(R.id.pulsator);         pulsator.start();         count = findViewById(R.id.count);         duration = findViewById(R.id.duration);                  // on change in seekbar value         count.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {             @Override             public void onProgressChanged(SeekBar seekBar, int i, boolean b) {                 // change the count                 pulsator.setCount(i);             }              @Override             public void onStartTrackingTouch(SeekBar seekBar) {              }              @Override             public void onStopTrackingTouch(SeekBar seekBar) {              }         });                  // on change in seekbar value         duration.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {             @Override             public void onProgressChanged(SeekBar seekBar, int i, boolean b) {                 // change the duration                 pulsator.setDuration(i);             }              @Override             public void onStartTrackingTouch(SeekBar seekBar) {              }              @Override             public void onStopTrackingTouch(SeekBar seekBar) {              }         });     }      @Override     protected void onStart() {         super.onStart();      } } 

Next Article
Pulse Animation View in Android

A

annianni
Improve
Article Tags :
  • Java
  • Android
  • Android-Animation
Practice Tags :
  • Java

Similar Reads

    Wave Animation in Android
    Wave Animation is one of the most commonly used features in Android app. You can see this animation in most of the shopping apps, music player apps, and many more. Using this Wave Animation makes the User Experience attractive. In this article, we are going to see how to implement Wave Animation in
    2 min read
    Android Animations in Kotlin
    Animation is a method in which a collection of images are combined in a specific way and processed then they appear as moving images. Building animations make on-screen objects seem to be alive. Android has quite a few tools to help you create animations with relative ease. so in this article we wil
    5 min read
    Animation in Android with Example
    Animation is the process of adding a motion effect to any view, image, or text. With the help of an animation, you can add motion or can change the shape of a specific view. Animation in Android is generally used to give your UI a rich look and feel. The animations are basically of three types as fo
    7 min read
    Circular Reveal Animation in Android
    Animations in Android play an important role in the user experience. This makes the user focus on the main content, which they want. And also helps in user interactivity. Animations communicate with the user to really get engaged in application usage. So in this article, one of the animations in and
    8 min read
    Typing Animation Effect in Android
    In this article, we are going to implement a very important feature related to TextView. This feature can be used to show important announcements or notifications in an App. Even we can add this feature to show important links for the user as this attracts the attention of the user. So here we are g
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences