Open In App
Related Articles

How to Create Balloon Toast Message in Android?

Improve Article
Save Article
Like Article

In this article, we are going to creating a balloon Toast. This Library is one of the popular features that is commonly used in most Android Apps. We can get to see this feature in most of the shopping and messaging apps. With the help of this feature, you can get a hint about what to do next in any app. Here in the output, we can see what we are going to do in this article.

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 Kotlin as the programming language. 

Step 2: Add dependency and JitPack Repository

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

implementation ‘com.github.BeppiMenozzi:BalloonPopup:0.2.8’

Add the JitPack repository to your build file. Add it to your root build.gradle at the end of repositories inside the allprojects{ } section.

allprojects {

 repositories {


   maven { url “” }



Step 3: 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. 


<?xml version="1.0" encoding="utf-8"?>
        android:textStyle="bold" />

Step 4: Working with the MainActivity.kt file

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


import android.os.Bundle
import it.beppi.balloonpopuplibrary.BalloonPopup
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        val bp = BalloonPopup.Builder(applicationContext, findViewById(
                .text("Showing Balloon Toast")    // set the text displayed (String or resource)
                .timeToLive(5000)                 // Milliseconds before closing the popup. 0 = persistent
                .animation(BalloonPopup.BalloonAnimation.fade_and_scale)    // animation style used. Available:
                // pop, scale, fade, fade75
                // and all the possible combinations.
                // When fade75 is used (up to alpha .75) the view is slightly transparent
                .shape(BalloonPopup.BalloonShape.rounded_square)      // Circle (oval) or rounded square
                .bgColor(Color.CYAN)        // unused yet
                .fgColor(Color.RED)         // text color
                .textSize(20)               // text size
                .offsetX(10)                // offsets to move the position accordingly
                .positionOffset(510, 815)
                .drawable(R.drawable.bg_circle) // custom background drawable


Last Updated : 18 Apr, 2021
Like Article
Save Article
Similar Reads