Version 21.0.0 API 23+ Maven Central Apache 2.0

Beautiful Material Alert Dialogs for Android

KAlertDialog is a modern, customizable, Material-style Android AlertDialog library for professional apps. Build success, error, warning, progress, input, custom view, URL image, and dark-mode dialogs with clean Java code.

Gradle dependency
dependencies {
    implementation 'io.github.tutorialsandroid:kalertdialog:21.0.0'
    implementation 'io.github.tutorialsandroid:progressx:7.0.5'
}
Features

Everything you need for production-ready Android dialogs.

KAlertDialog includes modern presets, dark mode, custom views, input validation, image loading, progress helpers, button styling, font customization, and dynamic alert type changes.

Material-style dialogs

Create beautiful success, error, warning, normal, progress, input, custom image, URL image, and custom view dialogs.

Auto dark mode

Use the autoNightMode constructor to automatically adapt dialogs when your Android app runs in night mode.

Advanced customization

Control title, content, fonts, font weight, colors, alignment, buttons, icons, radius, elevation, and dim amount.

Input validation

Build input dialogs with hint, default text, input type, max length, validation, and custom confirm callbacks.

Custom view support

Attach your own XML layout or custom View inside KAlertDialog using CUSTOM_VIEW_TYPE.

Dynamic alert type change

Switch from warning to success, error, or other dialog states after user actions.

🖼

URL image dialogs

Load remote images with circle crop, big image mode, placeholder, and error drawable support.

Progress shortcuts

Use helper methods or direct shortcut APIs to customize progress color, radius, speed, and value.

Modern callbacks

Use onConfirm, onCancel, onDialogShow, and onDialogDismiss for cleaner callback-style code.

Latest Release

Version 21.0.0

A major update focused on modern UI customization, better input handling, custom views, advanced button APIs, and improved documentation.

21.0.0

Released on 21-05-2026

  • Added option to set font weight for title and content.
  • Added modern style presets.
  • Added dialog corner radius customization.
  • Added dialog elevation customization.
  • Added dialog dim amount customization.
  • Added input validation support.
  • Added input max length support.
  • Added input type support.
  • Added custom view dialog support.
  • Added button text size customization.
  • Added button font weight customization.
  • Added button all-caps control.
  • Added button icon support.
  • Added URL image placeholder support.
  • Added URL image error drawable support.
  • Added progress shortcut methods.
  • Added show and dismiss callback APIs.
  • Updated compileSdk and targetSdk to 37.
Setup

Install KAlertDialog

Add Maven Central and JitPack, then add KAlertDialog and ProgressX dependencies to your Android project.

Step 1: Add repositories

settings.gradle
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Step 2: Add dependencies

app/build.gradle
dependencies {
    implementation 'io.github.tutorialsandroid:kalertdialog:21.0.0'
    implementation 'io.github.tutorialsandroid:progressx:7.0.5'
}

Important: compileSdk requirement

Latest KAlertDialog and ProgressX versions require your app to compile against Android API 37 or higher. Updating compileSdk is different from changing targetSdk or minSdk.

Required configuration
android {
    compileSdk 37

    defaultConfig {
        minSdk 23
        targetSdk 36
    }
}
Documentation

Usage examples

Copy-paste ready examples for common KAlertDialog use cases.

Basic message

Create a simple dialog with only title text.

Java
new KAlertDialog(this)
        .setTitleText("Here's a message!")
        .show();

Dialog types

KAlertDialog supports normal, success, error, warning, progress, input, image, URL image, and custom view dialogs.

Java
KAlertDialog.NORMAL_TYPE
KAlertDialog.ERROR_TYPE
KAlertDialog.SUCCESS_TYPE
KAlertDialog.WARNING_TYPE
KAlertDialog.CUSTOM_IMAGE_TYPE
KAlertDialog.URL_IMAGE_TYPE
KAlertDialog.PROGRESS_TYPE
KAlertDialog.INPUT_TYPE
KAlertDialog.CUSTOM_VIEW_TYPE

Modern style preset

Apply a modern style preset with professional radius, elevation, dim amount, and button styling.

Java
new KAlertDialog(this, KAlertDialog.SUCCESS_TYPE, true)
        .setTitleText("Success")
        .setContentText("Your changes were saved successfully.")
        .applyStyle(KAlertDialog.STYLE_MODERN)
        .setConfirmClickListener("Done", dialog -> dialog.dismissWithAnimation())
        .show();

Custom dialog appearance

Control dialog corner radius, elevation, dim amount, and background color.

Java
new KAlertDialog(this, KAlertDialog.NORMAL_TYPE, true)
        .setTitleText("Custom Appearance")
        .setContentText("This dialog has custom radius, elevation and dim amount.")
        .setDialogCornerRadius(30)
        .setDialogElevation(14)
        .setDimAmount(0.55f)
        .setConfirmClickListener("Looks Good", null)
        .show();

Progress dialog

Show loading or processing states with progress helper APIs or direct shortcut methods.

Java
new KAlertDialog(this, KAlertDialog.PROGRESS_TYPE, true)
        .setTitleText("Processing")
        .setContentText("Please wait while we prepare your request.")
        .applyStyle(KAlertDialog.STYLE_MODERN)
        .setProgressColor(Color.parseColor("#10B981"))
        .setProgressSpinSpeed(1.1f)
        .show();

Input dialog with validation

Validate input before confirming and show an error message directly in the input field.

Java
new KAlertDialog(this, KAlertDialog.INPUT_TYPE, true)
        .setTitleText("Create Project")
        .setContentText("Enter a project name with at least 3 characters.")
        .applyStyle(KAlertDialog.STYLE_MODERN)
        .setInputFieldHint("Project name")
        .setInputFieldText("KAlertDialog")
        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS)
        .setInputMaxLength(30)
        .setInputError("Project name must be at least 3 characters")
        .setInputValidator(input -> input != null && input.trim().length() >= 3)
        .setOnInputConfirmListener((dialog, input) -> {
            dialog.dismissWithAnimation();
            Toast.makeText(this, "Created: " + input.trim(), Toast.LENGTH_SHORT).show();
        })
        .setConfirmClickListener("Create", null)
        .show();

Custom view dialog

Attach your own XML layout inside KAlertDialog and access its views using getCustomView().

Java
KAlertDialog dialog = new KAlertDialog(this, KAlertDialog.CUSTOM_VIEW_TYPE, true)
        .setTitleText("Custom View")
        .setContentText("This dialog uses your custom XML layout.")
        .applyStyle(KAlertDialog.STYLE_MODERN)
        .setCustomView(R.layout.customedittext)
        .showCancelButton(true)
        .setCancelClickListener("Cancel", kAlertDialog -> kAlertDialog.dismissWithAnimation());

dialog.setConfirmClickListener("Save", kAlertDialog -> {
    View customView = kAlertDialog.getCustomView();

    if (customView == null) {
        return;
    }

    EditText editText = customView.findViewById(R.id.edit_query);
    String value = editText.getText().toString().trim();

    if (value.length() < 3) {
        editText.setError("Please enter at least 3 characters");
        return;
    }

    kAlertDialog.dismissWithAnimation();
});

dialog.show();

URL image dialog

Load remote images as circle crop or big images with placeholder and error fallback.

Java
new KAlertDialog(this, KAlertDialog.URL_IMAGE_TYPE, true)
        .setTitleText("Big URL Image")
        .setContentText("This image is loaded from a URL as a large image.")
        .applyStyle(KAlertDialog.STYLE_ROUNDED)
        .setURLImagePlaceholder(R.mipmap.ic_launcher)
        .setURLImageError(R.mipmap.ic_launcher)
        .setURLImage("https://example.com/image.png", KAlertDialog.IMAGE_BIG)
        .setConfirmClickListener("Close", null)
        .show();

Font and font weight

Use fonts from assets or res/font and apply font weight to title, content, and buttons.

Java
new KAlertDialog(this, KAlertDialog.NORMAL_TYPE, true)
        .setTitleText("Font Weight")
        .setContentText("Title is bold and content is italic.")
        .setTitleFontAssets("fonts/os.ttf")
        .setContentFontAssets("fonts/poppins_regular.ttf")
        .setTitleFontWeight(Typeface.BOLD)
        .setContentFontWeight(Typeface.ITALIC)
        .setConfirmClickListener("OK", null)
        .show();

Button customization

Customize button text size, font weight, all-caps behavior, icons, colors, and drawable backgrounds.

Java
new KAlertDialog(this, KAlertDialog.NORMAL_TYPE, true)
        .setTitleText("Button Styling")
        .setContentText("This example shows button text size, font weight, all caps control and button icons.")
        .applyStyle(KAlertDialog.STYLE_MINIMAL)
        .showCancelButton(true)
        .setConfirmButtonTextSize(15)
        .setCancelButtonTextSize(15)
        .setConfirmButtonFontWeight(Typeface.BOLD)
        .setCancelButtonFontWeight(Typeface.BOLD)
        .setConfirmButtonAllCaps(false)
        .setCancelButtonAllCaps(false)
        .setConfirmButtonIcon(android.R.drawable.checkbox_on_background)
        .setCancelButtonIcon(android.R.drawable.ic_menu_close_clear_cancel)
        .setConfirmClickListener("Accept", dialog -> dialog.dismissWithAnimation())
        .setCancelClickListener("Decline", dialog -> dialog.dismissWithAnimation())
        .show();

Modern callbacks

Use callback-style APIs for confirm, cancel, show, and dismiss events.

Java
new KAlertDialog(this, KAlertDialog.NORMAL_TYPE, true)
        .setTitleText("Callbacks")
        .setContentText("This dialog shows modern listener APIs.")
        .applyStyle(KAlertDialog.STYLE_MODERN)
        .showCancelButton(true)
        .onDialogShow(dialog -> {
            Toast.makeText(this, "Dialog shown", Toast.LENGTH_SHORT).show();
        })
        .onDialogDismiss(dialog -> {
            Toast.makeText(this, "Dialog dismissed", Toast.LENGTH_SHORT).show();
        })
        .onConfirm(dialog -> {
            Toast.makeText(this, "Confirmed", Toast.LENGTH_SHORT).show();
            dialog.dismissWithAnimation();
        })
        .onCancel(dialog -> {
            Toast.makeText(this, "Cancelled", Toast.LENGTH_SHORT).show();
            dialog.dismissWithAnimation();
        })
        .setConfirmClickListener("Confirm", null)
        .setCancelClickListener("Cancel", null)
        .show();

Dynamic alert type change

Change the alert type after user interaction, such as warning to success or error.

Java
new KAlertDialog(this, KAlertDialog.WARNING_TYPE, true)
        .setTitleText("Are you sure?")
        .setContentText("You won't be able to recover this file!")
        .showCancelButton(true)
        .setCancelClickListener("Cancel", dialog -> {
            dialog.setTitleText("Cancelled")
                    .setContentText("Your file is safe.")
                    .showCancelButton(false)
                    .setConfirmClickListener("OK", null)
                    .changeAlertType(KAlertDialog.ERROR_TYPE);
        })
        .setConfirmClickListener("Delete", dialog -> {
            dialog.setTitleText("Deleted")
                    .setContentText("Your file has been deleted.")
                    .showCancelButton(false)
                    .setConfirmClickListener("OK", null)
                    .changeAlertType(KAlertDialog.SUCCESS_TYPE);
        })
        .show();
API Summary

Quick API reference

The most-used constants and methods in one place.

Constructors

new KAlertDialog(context)
new KAlertDialog(context, autoNightMode)
new KAlertDialog(context, alertType, autoNightMode)

Dialog types

KAlertDialog.NORMAL_TYPE
KAlertDialog.ERROR_TYPE
KAlertDialog.SUCCESS_TYPE
KAlertDialog.WARNING_TYPE
KAlertDialog.CUSTOM_IMAGE_TYPE
KAlertDialog.URL_IMAGE_TYPE
KAlertDialog.PROGRESS_TYPE
KAlertDialog.INPUT_TYPE
KAlertDialog.CUSTOM_VIEW_TYPE

Style presets

KAlertDialog.STYLE_CLASSIC
KAlertDialog.STYLE_MODERN
KAlertDialog.STYLE_MINIMAL
KAlertDialog.STYLE_ROUNDED

Text methods

.setTitleText("Title")
.setContentText("Content")
.setTitleTextSize(20)
.setContentTextSize(16)
.setTitleColor(R.color.color)
.setContentColor(R.color.color)
.setTitleFontWeight(Typeface.BOLD)
.setContentFontWeight(Typeface.NORMAL)

Button methods

.setConfirmClickListener("OK", listener)
.setCancelClickListener("Cancel", listener)
.showConfirmButton(true)
.showCancelButton(true)
.setConfirmButtonTextSize(15)
.setConfirmButtonFontWeight(Typeface.BOLD)
.setConfirmButtonAllCaps(false)
.setConfirmButtonIcon(R.drawable.icon)

Input methods

.setInputFieldHint("Hint")
.setInputFieldText("Default text")
.setInputType(InputType.TYPE_CLASS_TEXT)
.setInputMaxLength(30)
.setInputError("Error message")
.setInputValidator(input -> input.trim().length() >= 3)
.setOnInputConfirmListener((dialog, input) -> { })
.getInputText()

Custom view methods

.setCustomView(R.layout.custom_layout)
.setCustomView(view)
.getCustomView()

URL image methods

.setURLImage("https://example.com/image.png", KAlertDialog.IMAGE_CIRCLE)
.setURLImage("https://example.com/image.png", KAlertDialog.IMAGE_BIG)
.setURLImagePlaceholder(R.drawable.placeholder)
.setURLImageError(R.drawable.error_image)

Progress methods

.getProgressHelper()
.setProgressColor(Color.GREEN)
.setProgressColorResource(R.color.color)
.setProgressWidth(6)
.setProgressValue(0.5f)
.setProgressInstantValue(0.5f)
.setProgressSpinSpeed(1.1f)
.setProgressCircleRadius(80)

Callbacks

.onConfirm(dialog -> { })
.onCancel(dialog -> { })
.onDialogShow(dialog -> { })
.onDialogDismiss(dialog -> { })
FAQ

Common questions

Quick answers for setup and common issues.

What is KAlertDialog?

KAlertDialog is a modern Material-style Android AlertDialog library for Java Android apps. It supports success, error, warning, progress, input, custom image, URL image, and custom view dialogs.

What compileSdk is required?

KAlertDialog 21.0.0 requires compileSdk 37 or higher because the latest KAlertDialog and ProgressX libraries are compiled with Android API 37.

Does updating compileSdk change targetSdk behavior?

No. compileSdk controls which APIs your app can compile against. targetSdk controls Android runtime behavior changes, and minSdk controls the minimum installable Android version.

Does KAlertDialog support dark mode?

Yes. Pass true in the constructor to enable auto dark mode behavior.

Can I add my own custom layout?

Yes. Use CUSTOM_VIEW_TYPE with setCustomView(R.layout.your_layout) or setCustomView(view), then access it using getCustomView().

Why is my big URL image small?

Make sure custom_big_image has a fixed height such as 170dp, the parent image frame has match_parent width, and IMAGE_BIG uses centerCrop in Glide.

Open Source

Build beautiful Android dialogs faster with KAlertDialog.

Install the latest version, explore the sample app, and star the GitHub repository if this library helps your Android projects.

Copied to clipboard