Skip to content
Customise your dialogs the new way
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gradle/2.10 First commit Nov 3, 2016
.idea Update Sample Dec 21, 2016
app Update Sample Dec 21, 2016
customdialogs Update Sample Dec 21, 2016
gradle/wrapper Update Sample Dec 21, 2016
.gitignore Add files to publish library Nov 4, 2016
CustomizableDialogs.iml First commit Nov 3, 2016 Update Dec 24, 2016
aman.iml First commit Nov 3, 2016
build.gradle Update Sample Dec 21, 2016 Add files to publish library Nov 4, 2016
gradlew First commit Nov 3, 2016
gradlew.bat First commit Nov 3, 2016 Update Sample Dec 21, 2016
settings.gradle First commit Nov 3, 2016

Custom Dialogs

Basic useful feature list:

  • Create simple dialog box.
  • Customise colors, buttons, position on screen.
  • Change dim value and transparency of the dialog box.
  • Modify Text, images as if handling a TextView or ImageView.
  • Auto-dismiss
  • Block clicks outside the dialog box.


  • Download the library customdialogs

  • Create an object of class CustomDialogs

    CustomDialogs.OnButtonClickListener positiveButton = new CustomDialogs.OnButtonClickListener() {
            public void onButtonClick() {
            //customize what happens on the button click!
                Toast.makeText(getApplicationContext(), "Positive Button Clicked!", Toast.LENGTH_LONG).show();
            public boolean dismissOnClick() {
            // return true if the dialog dismisses on button click
            // else false
                return true;
    CustomDialogs dialog = CustomDialogs(context, "message",, "positiveButtonText", positiveButton);

    For creating dialog boxes without an image, use the following constructor:

    CustomDialogs noImageDialog = new CustomDialog (Context context, String message, String positiveButtonText, OnButtonClickListener onPositiveClickListener);
  • Add negative and neutral buttons by creating objects negeativeButton and neutralButton of the interface CustomDialogs.OnButtonClickListener, then call

    dialog.enableNeutralButton("Neutral", neutralButton);
    dialog.enableNegativeButton("-ve", negativeButton);

    Add a negative button before creating a neutral button.

  • To make the dialog box transparent make the following call to the method:

  • Set the dim value (outside the dialog). value is a float from 0 to 1f

  • Auto dismiss dialog box after after t secs

    dialog.dismissAfter(t * 1000);
  • Position dialog box

     dialog.positionDialog(DialogGravity.START);  // to align dialog to the left of the screen  		  
     dialog.positionDialog(DialogGravity.END);    // to align dialog to the right of the screen  		  
  • Change Background

       dialog.setBackground(Drawable drawableBackground);
       // to set a speccific color use
       dialog.setBackground(new ColorDrawable(Color.rgb(66, 244, 167))); 
       // plug in the the RGB values of the required color.
       // or: 
       dialog.setBackground(new ColorDrawable(Color.argb(255, 66, 244, 167)));
       // the first parameter is the alpha value [0, 255]
  • Block clicks outside the Dialog

  • Displaying the dialog;
  • To customize the message, image and buttons make the following method calls after displaying the dialog box:

      ImageView dialogImage = dialog.getImageDrawable();
      TextView dialogMessage = dialog.getMessage();
      TextView positiveButtonTV = dialog.getPositiveButton();
      TextView neutralButtonTV = dialog.getNeutralButton();
      TextView negativeButtonTV = dialog.getNegativeButton();
You can’t perform that action at this time.