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
  • DSA Tutorial
  • Data Structures
  • Algorithms
  • Array
  • Strings
  • Linked List
  • Stack
  • Queue
  • Tree
  • Graph
  • Searching
  • Sorting
  • Recursion
  • Dynamic Programming
  • Binary Tree
  • Binary Search Tree
  • Heap
  • Hashing
  • Divide & Conquer
  • Mathematical
  • Geometric
  • Bitwise
  • Greedy
  • Backtracking
  • Branch and Bound
  • Matrix
  • Pattern Searching
  • Randomized
Open In App
Next Article:
BubbleEmitter animation in Android with Examples
Next article icon

BubbleEmitter animation in Android with Examples

Last Updated : 20 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

BubbleEmitter is an animation library that helps to gain the attention of the user. It shows fancy animated bubbles in an Android view. It is used to create a beautiful user interface where the user can feel the app in real. Some useful features and applications of BubbleEmitter are:

  • To create a live wallpaper app BubbleEmitter can be used for this.
  • Use this view where if you want the user to wait for some time.
  • ProgressBar can be used instead of this but because of its unique UI, it will attract the user and hence users wait for enough time.
  • It also provides full control to the developer.
  • One can also create a custom colourful bubble.

Approach

Step 1: Add the support library in the root build.gradle file (not in module build.gradle file). This library jitpack is a novel package repository. It is made for JVM so that any library which is present in github and Bitbucketin can be directly used in the application.

allprojects {             repositories {                    maven { url 'https://jitpack.io' }                 }           }           


Step 2: Add the support library in build.gradle file and add dependency in the dependencies section.

implementation 'com.github.FireZenk:BubbleEmitter:-SNAPSHOT' 


Step 3: Add the following code in activity_main.xml file. In this file add BubbleEmitter to the layout. activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout     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"     tools:context=".MainActivity">          <org.firezenk.bubbleemitter.BubbleEmitterView         android:id="@+id/bubbleEmitter"         android:layout_width="match_parent"         android:layout_height="match_parent"         app:layout_constraintBottom_toBottomOf="parent"         app:layout_constraintLeft_toLeftOf="parent"         app:layout_constraintRight_toRightOf="parent"         app:layout_constraintTop_toTopOf="parent"/>  </androidx.constraintlayout.widget.ConstraintLayout>   


Step 4: Add the following code in MainActivity.kt file. In this file create a thread and attach it to the main thread. MainActivity.kt

package org.geeksforgeeks.bubbleemitter            import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Handler import kotlinx.android.synthetic.main.activity_main.* import kotlin.random.Random  class MainActivity : AppCompatActivity() {     override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)         emitBubbles()     }      private fun emitBubbles() {         // It will create a thread and attach it to         // the main thread         Handler().postDelayed({             // Random is used to select random bubble             // size             val size = Random.nextInt(20, 80)             bubbleEmitter.emitBubble(size)             emitBubbles()         }, Random.nextLong(100, 500))     } } 


Output: Run on Emulator


Step 5: To add color in bubbles add the following code in MainActivity.kt file. In this file we are going create black color bubbles. MainActivity.kt

package org.geeksforgeeks.bubbleemitter            import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.os.Handler import kotlinx.android.synthetic.main.activity_main.* import kotlin.random.Random  class MainActivity : AppCompatActivity() {     override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)         emitBubbles()     }      private fun emitBubbles() {         // It will create a thread and attach it to         // the main thread         Handler().postDelayed({             // Random is used to select random bubble             // size             val size = Random.nextInt(20, 80)             bubbleEmitter.emitBubble(size)             bubbleEmitter.setColors(android.R.color.black,                 android.R.color.black,                 android.R.color.black);             emitBubbles()         }, Random.nextLong(100, 500))     } } 


Output: Run on Emulator


Next Article
BubbleEmitter animation in Android with Examples

M

madhavmaheshwarimm20
Improve
Article Tags :
  • Kotlin
  • Android
  • DSA
  • Android-Animation

Similar Reads

    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
    BungeeAnimation in Android with Example
    BungeeAnimation is an animation library that helps to gain the attention of the user. As it is known that apps are made up of many activities so it is common for the user to travel between different activities in an app. By adding animation to those transactions it will surely attract users. Activit
    5 min read
    Explode Animation in Android
    In this article, we are going to show the android explode animation. This is something that is very interesting. You may have seen this feature in some game apps or even many money transfer apps. They show rewards like this. When you click on the reward it will explode and will show the reward that
    2 min read
    Pulse Animation View in Android
    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 th
    4 min read
    Slide Animation in Android with Kotlin
    Animations in Android allow UI elements to perform aesthetic moves across the screen. Animations can be implemented from a third party as well as developed from scratch. Despite the source, animations can be applied to any kind of view or UI element. Typically, we have demonstrated a slide animation
    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