Skip to content

AnuhasRox/CustomAlertDialog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Animated AlertDialog

Animated AlertDialog With Rounded Corners

Alert Dialog Style

First you need add this code to your project themes.xml file

    <style name="MaterialAlertDialog.Rounded" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
        <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.MaterialAlertDialog.Rounded</item>
    </style>

    <style name="ShapeAppearanceOverlay.MaterialAlertDialog.Rounded" parent="">
        <item name="cornerSize">10dp</item>
    </style>

For Activity

Follow this step to add animated alert dialog

  1. Copy this code
private void launchAlertDialog() {
        new MaterialAlertDialogBuilder(AlertDialog.this, R.style.MaterialAlertDialog_Rounded)
                .setTitle("Quity update required")
                .setMessage("Quity recommends that you to update to latest version")
                .setPositiveButton("Update", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int i) {
                        try {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.anuhas.quity")));
                        }catch (Exception e){
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.anuhas.quity")));
                        }
                    }
                })
                .setCancelable(false)
                .show();

    }
  1. After that, paste in your activity like this
  2. Now you can call alert dialog using this code launchAlertDialog();

For Fragment

Follow this step to add animated alert dialog

  1. Copy this code
private void launchAlertDialog() {
        new MaterialAlertDialogBuilder(getcontext(), R.style.MaterialAlertDialog_Rounded)
                .setTitle("Quity update required")
                .setMessage("Quity recommends that you to update to latest version")
                .setPositiveButton("Update", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int i) {
                        try {
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.anuhas.quity")));
                        }catch (Exception e){
                            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=com.anuhas.quity")));
                        }
                    }
                })
                .setCancelable(false)
                .show();

    }
  1. After that, paste in your activity like this
  2. Now you can call alert dialog using this code launchAlertDialog();

Releases

No releases published

Packages

No packages published

Languages