Open In App
Related Articles

How to Create CircularDialog in Android?

Like Article
Save Article
Report issue

CircularDialog is another best way of representing information or data in an Android app. You can get to see these Circular Dialogs in most of the apps which are used to display the message of completion of the process in an attractive form. In this article, we are going to see how to implement Circular Dialogs 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. 

CircularDialog in Android Sample GIF

Application of Circular Dialogs

  • Use to represent the message in an attractive form.
  • Circular Dialogs is a unique way of representing messages in the alert dialog box.
  • Create a good quality User Experience.

Attributes of Circular Dialog



CDConstants.SUCCESSTo display Success message on a Circular Dialog.
 .setAnimationUse to set Set Animation to Circular Dialog.
.setTextSizeUse to set Set text size in Circular Dialog.
.setDurationUse to set Animation time in milliSeconds.
 CDConstants.LARGEUse to set the size of Dialog.

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 and JitPack Repository

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

implementation ‘com.github.hassanusman:CircularDialogs:1.2’

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 “” }



After adding this dependency sync your project and now we will move towards its implementation.  

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"?>
    <!--After clicking button you will
        get circular dialog-->
        android:text="CLICK" />


Step 4: Working with the file

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


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import com.example.circulardialog.CDialog;
import com.example.circulardialog.extras.CDConstants;
public class MainActivity extends AppCompatActivity {
    // Initialize button
    Button button;
    protected void onCreate(Bundle savedInstanceState) {
        // Called button by Id
        button = (Button) findViewById(;
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                // Circular Dialog Box Created
                new CDialog(MainActivity.this).createAlert("Great",
                        CDConstants.SUCCESS,   // Type of dialog
                        CDConstants.LARGE)     // Size of dialog
                        .setAnimation(CDConstants.SLIDE_FROM_BOTTOM_TO_TOP)  // Animation for enter/exit
                        .setDuration(2000)   // in milliseconds
                        .setTextSize(CDConstants.LARGE_TEXT_SIZE)  // CDConstants.LARGE_TEXT_SIZE, 
                                                                   // CDConstants.NORMAL_TEXT_SIZE


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.


Last Updated : 31 Jan, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads