{"id":16757162,"url":"https://github.com/patilshreyas/materialdialog-android","last_synced_at":"2025-05-15T21:06:53.322Z","repository":{"id":40336080,"uuid":"190720182","full_name":"PatilShreyas/MaterialDialog-Android","owner":"PatilShreyas","description":"📱Android Library to implement animated, 😍beautiful, 🎨stylish Material Dialog in android apps easily.","archived":false,"fork":false,"pushed_at":"2022-01-08T05:49:33.000Z","size":10408,"stargazers_count":931,"open_issues_count":5,"forks_count":143,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-15T21:06:18.844Z","etag":null,"topics":["android","android-library","android-ui","animation-library","dialog","hacktoberfest","lottie","material-design","material-dialog","material-ui"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PatilShreyas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":"PatilShreyas","otechie":null,"custom":["https://www.paypal.me/PatilShreyas99/"]}},"created_at":"2019-06-07T09:39:57.000Z","updated_at":"2025-05-15T12:34:11.000Z","dependencies_parsed_at":"2022-08-09T17:31:10.411Z","dependency_job_id":null,"html_url":"https://github.com/PatilShreyas/MaterialDialog-Android","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatilShreyas%2FMaterialDialog-Android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatilShreyas%2FMaterialDialog-Android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatilShreyas%2FMaterialDialog-Android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatilShreyas%2FMaterialDialog-Android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PatilShreyas","download_url":"https://codeload.github.com/PatilShreyas/MaterialDialog-Android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254422764,"owners_count":22068678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","android-ui","animation-library","dialog","hacktoberfest","lottie","material-design","material-dialog","material-ui"],"created_at":"2024-10-13T03:43:03.466Z","updated_at":"2025-05-15T21:06:53.302Z","avatar_url":"https://github.com/PatilShreyas.png","language":"Java","funding_links":["https://issuehunt.io/r/PatilShreyas","https://www.paypal.me/PatilShreyas99/"],"categories":[],"sub_categories":[],"readme":"![Maven Central](https://img.shields.io/maven-central/v/dev.shreyaspatil.MaterialDialog/MaterialDialog)\n![API](https://img.shields.io/badge/API-19%2B-brightgreen.svg)\n[![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23392-2CA3E6.svg?style=flat)](http://androidweekly.net/issues/issue-392)\n\n![Github Followers](https://img.shields.io/github/followers/PatilShreyas?label=Follow\u0026style=social)\n![GitHub stars](https://img.shields.io/github/stars/PatilShreyas/MaterialDialog-Android?style=social)\n![GitHub forks](https://img.shields.io/github/forks/PatilShreyas/MaterialDialog-Android?style=social)\n![GitHub watchers](https://img.shields.io/github/watchers/PatilShreyas/MaterialDialog-Android?style=social)\n![Twitter Follow](https://img.shields.io/twitter/follow/imShreyasPatil?label=Follow\u0026style=social)\n\n\n# Material Dialogs for Android 📱\n\n📱Android Library to implement *animated*, 😍*beautiful*, 🎨*stylish* Material Dialog in android apps easily.\n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\u003cb\u003e1. Material Dialog\u003cb\u003e\u003c/b\u003e\u003c/th\u003e\n    \u003cth\u003e2. Animated Material Dialog\u003c/th\u003e \n    \u003cth\u003e3. Bottom Sheet Material Dialog\u003c/th\u003e\n    \u003cth\u003e4. Animated Bottom Sheet Material Dialog\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"GIFs/SimpleMaterialDialog.gif\"/\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"GIFs/AnimatedMaterialDialog.gif\"/\u003e\u003c/td\u003e \n    \u003ctd\u003e\u003cimg src=\"GIFs/BottomSheetMaterialDialog.gif\"/\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"GIFs/AnimatedBottomSheetMaterialDialog.gif\"/\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\n# Table of Contents:\n\u003e - [ Introduction ](#introduction)\n\u003e - [ Types of Dialog ](#types)\n\u003e - [ Implementation ](#implementation)\n\u003e    - [ Prerequisite ](#prerequisite)\n\u003e    - [ Create Dialog Instance ](#createDialogInstance)\n\u003e        - [ Material Dialog ](#createMaterialDialog)\n\u003e        - [ Bottom Sheet Material Dialog ](#createBsMaterialDialog)\n\u003e    - [ Text Alignment ](#textAlignment)\n\u003e    - [ HTML formatting for Message ](#htmlFormatting)\n\u003e    - [ Show Animations ](#showAnims)\n\u003e        - [ Using `Resource` File ](#showAnimRes)\n\u003e        - [ Using `Asset` File ](#showAnimFile)\n\u003e        - [ Getting `LottieAnimationView` ](#getLottieAnimationView)\n\u003e    - [ Dialog State Listeners ](#stateCallbacks)\n\u003e - [ Contribute ](#contribute)    \n\u003e - [ Credits ](#credits)    \n\n\u003ca name=\"introduction\"\u003e\u003c/a\u003e\n## Introduction\n**MaterialDialog** library is built upon Google's Material Design library. This API will be useful to create rich, animated, beautiful dialogs in Android app easily. \nThis library implements Airbnb's [*Lottie*](https://github.com/airbnb/lottie-android) library to render After Effects animation in app.\nRefer [this](https://airbnb.io/lottie/#/) for Lottie documentation.\n\n\u003ca name=\"types\"\u003e\u003c/a\u003e\n## Types of Dialog\n**MaterialDialog** library provides two types of dialog i.e. \n\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\u003cb\u003e1. Material Dialog\u003cb\u003e\u003c/b\u003e\u003c/th\u003e\n    \u003cth\u003e2. Bottom Sheet Material Dialog\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eThis is basic material dialog which has two material buttons (Same as Android's AlertDialog) as you can see below.\u003c/td\u003e\n    \u003ctd\u003eThis is Bottom Sheet material dialog which has two material buttons which is showed from bottom of device as you can see below.\u003c/td\u003e \n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003cimg src=\"Screenshots/MaterialDialog.png\" width=\"75%\"/\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003cimg src=\"Screenshots/BottomSheetMaterialDialog.png\" width=\"75%\"/\u003e\u003c/td\u003e \n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003ca name=\"implementation\"\u003e\u003c/a\u003e\n## Implementation\nImplementation of Material Dialog library is so easy. You can check [/app](/app) directory for demo. Let's have look on basic steps of implementation.\n\u003ca name=\"prerequisite\"\u003e\u003c/a\u003e\n### Prerequisite\n#### i. Gradle\nIn `Build.gradle` of app module, include these dependencies. If you want to show animations, include *Lottie* animation library.\n\nThis library is available on [MavenCentreal](https://search.maven.org/artifact/dev.shreyaspatil.MaterialDialog/MaterialDialog/)\n\n```groovy\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n\n    // Material Dialog Library\n    implementation 'dev.shreyaspatil.MaterialDialog:MaterialDialog:2.2.3'\n\n    // Material Design Library\n    implementation 'com.google.android.material:material:1.0.0'\n\n    // Lottie Animation Library\n    implementation 'com.airbnb.android:lottie:3.3.6'\n}\n```\n#### ii. Set up Material Theme\nSetting Material Theme to app is necessary before implementing Material Dialog library. To set it up, update [`styles.xml`](app\\src\\main\\res\\values\\styles.xml) of `values` directory in app.\n```xml\n\u003cresources\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"Theme.MaterialComponents.Light\"\u003e\n        \u003c!-- Customize your theme here. --\u003e\n        ...\n    \u003c/style\u003e\n\u003c/resources\u003e\n```\nThese are required prerequisites to implement Material Dialog library.\n\n#### iii. Customize Dialog Theme (Optional)\nIf you want to customize dialog view, you can override style in `styles.xml` as below.\n```xml\n    \u003c!-- Base application theme. --\u003e\n    \u003cstyle name=\"AppTheme\" parent=\"Theme.MaterialComponents.Light.DarkActionBar\"\u003e\n        \u003citem name=\"colorPrimary\"\u003e@color/colorPrimary\u003c/item\u003e\n        \u003citem name=\"colorPrimaryDark\"\u003e@color/colorPrimaryDark\u003c/item\u003e\n        \u003citem name=\"colorAccent\"\u003e@color/colorAccent\u003c/item\u003e\n        \u003citem name=\"android:fontFamily\"\u003e@font/montserrat\u003c/item\u003e\n\n        \u003c!-- Customize your theme here. --\u003e\n        \u003citem name=\"material_dialog_background\"\u003e#FFFFFF\u003c/item\u003e\n        \u003citem name=\"material_dialog_title_text_color\"\u003e#000000\u003c/item\u003e\n        \u003citem name=\"material_dialog_message_text_color\"\u003e#5F5F5F\u003c/item\u003e\n        \u003citem name=\"material_dialog_positive_button_color\"\u003e@color/colorAccent\u003c/item\u003e\n        \u003citem name=\"material_dialog_positive_button_text_color\"\u003e#FFFFFF\u003c/item\u003e\n        \u003citem name=\"material_dialog_negative_button_text_color\"\u003e@color/colorAccent\u003c/item\u003e\n    \u003c/style\u003e\n```\n\n\u003ca name=\"createDialogInstance\"\u003e\u003c/a\u003e\n### Create Dialog Instance\nAs there are two types of dialogs in library. Material Dialogs are instantiated as follows.\n\u003ca name=\"createMaterialDialog\"\u003e\u003c/a\u003e\n#### i. Material Dialog\n`MaterialDialog` class is used to create Material Dialog. Its static `Builder` class is used to instantiate it. After building, to show the dialog, `show()` method of `MaterialDialog` is used.\n```java\n        MaterialDialog mDialog = new MaterialDialog.Builder(this)\n                .setTitle(\"Delete?\")\n                .setMessage(\"Are you sure want to delete this file?\")\n                .setCancelable(false)\n                .setPositiveButton(\"Delete\", R.drawable.ic_delete, new MaterialDialog.OnClickListener() {\n                    @Override\n                    public void onClick(DialogInterface dialogInterface, int which) {\n                        // Delete Operation\n                    }\n                })\n                .setNegativeButton(\"Cancel\", R.drawable.ic_close, new MaterialDialog.OnClickListener() {\n                    @Override\n                    public void onClick(DialogInterface dialogInterface, int which) {\n                        dialogInterface.dismiss();\n                    }\n                })\n                .build();\n\n        // Show Dialog\n        mDialog.show();\n```\n\n\u003cimg align=\"center\" src=\"GIFs/SimpleMaterialDialog.gif\" width=\"300\"/\u003e\n\n\u003ca name=\"createBsMaterialDialog\"\u003e\u003c/a\u003e\n#### ii. Bottom Sheet Material Dialog\n`BottomSheetMaterialDialog` class is used to create Bottom Sheet Material Dialog. Its static `Builder` class is used to instantiate it. After building, to show the dialog, `show()` method of `BottomSheetMaterialDialog` is used.\n```java\n        BottomSheetMaterialDialog mBottomSheetDialog = new BottomSheetMaterialDialog.Builder(this)\n                .setTitle(\"Delete?\")\n                .setMessage(\"Are you sure want to delete this file?\")\n                .setCancelable(false)\n                .setPositiveButton(\"Delete\", R.drawable.ic_delete, new BottomSheetMaterialDialog.OnClickListener() {\n                    @Override\n                    public void onClick(DialogInterface dialogInterface, int which) {\n                        Toast.makeText(getApplicationContext(), \"Deleted!\", Toast.LENGTH_SHORT).show();\n                        dialogInterface.dismiss();\n                    }\n                })\n                .setNegativeButton(\"Cancel\", R.drawable.ic_close, new BottomSheetMaterialDialog.OnClickListener() {\n                    @Override\n                    public void onClick(DialogInterface dialogInterface, int which) {\n                        Toast.makeText(getApplicationContext(), \"Cancelled!\", Toast.LENGTH_SHORT).show();\n                        dialogInterface.dismiss();\n                    }\n                })\n                .build();\n\n        // Show Dialog\n        mBottomSheetDialog.show();\n```\n\n\u003cimg align=\"center\" src=\"GIFs/BottomSheetMaterialDialog.gif\" width=\"300\"/\u003e\n\n\u003ca name=\"textAlignment\"\u003e\u003c/a\u003e\n### Text Alignment\n\nText alignment  is supported for _title_ and _message_ of a dialog. It's configurable while building a dialog.\nIf it's not provided in builder, `TextAlignment.CENTER` is considered by default i.e. it'll be always aligned in a ***center***.\n\n**Following Alignment Enum Values are allowed to be used for Dialog text alignment:**\n\n- `TextAlignment.START`: Aligns text at start / left.\n- `TextAlignment.CENTER`: Aligns text at center.\n- `TextAlignment.END`: Aligns text at end / right.\n\n**Example usage:**\n\n```java\n        MaterialDialog mDialog = new MaterialDialog.Builder(this)\n                .setTitle(\"Lorem Ipsum Title\", TextAlignment.START)\n                .setMessage(\"Lorem Ipsum Message\", TextAlignment.START)\n```\n\n\n\u003ca name=\"htmlFormatting\"\u003e\u003c/a\u003e\n\n### HTML formatting for Message\n\nHTML spanned text is supported only for dialog's ***message***. While setting a message, you can directly provide `Spanned` instance as shown in following example.\n\n```java\n        MaterialDialog mDialog = new MaterialDialog.Builder(this)\n                .setMessage(Html.fromText(\"\u003cb\u003eLorem \u003ci\u003eIpsum\u003c/i\u003e\u003c/b\u003e. \u003cbr\u003e Click \u003ca href=\\\"https://example.com\\\"\u003ehere\u003c/a\u003e for more information\"))\n```\n\n\u003ca name=\"showAnims\"\u003e\u003c/a\u003e\n### Show Animations\n\u003ctable style=\"width:100%\"\u003e\n  \u003ctr\u003e\n    \u003cth\u003eMaterial Dialog\u003c/th\u003e \n    \u003cth\u003eBottom Sheet Material Dialog\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003cimg src=\"GIFs/AnimatedMaterialDialog.gif\"/\u003e\u003c/td\u003e\n    \u003ctd\u003e\u003cimg src=\"GIFs/AnimatedBottomSheetMaterialDialog.gif\"/\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nAnimations in this library are implemented using Lottie animation library. You can get free animations files [here](https://lottiefiles.com/). You can find varieties of animation files on [https://lottiefiles.com](https://lottiefiles.com/).\n`*.json` file downloaded from *LottieFiles* should be placed in android project. There are two ways to place animation file (`*.json`).\n\nFor example, here `delete_anim.json` animation file is used to show file delete animation.\n\u003ca name=\"showAnimRes\"\u003e\u003c/a\u003e\n#### i. Using `Resource` File\nDownloaded json file should placed in `raw` directory of `res`.\n\n![](Screenshots/ScreenAnimRes.PNG)\n\nIn code, `setAnimation()` method of `Builder` is used to set Animation to the dialog.\n\nPrototype :\n\u003e setAnimation(int resourceId)\n\nResource file should be passed to method. e.g. `R.raw.delete_anim`. \n```java\n        MaterialButton mDialog = new MaterialDialog.Builder(this)\n                .setAnimation(R.raw.delete_anim)\n```\n\u003ca name=\"showAnimFile\"\u003e\u003c/a\u003e\n#### ii. Using `Asset` File\nDownloaded json file should placed in `asset` directory.\n\n![](Screenshots/ScreenAnimAsset.PNG)\n\nIn code, `setAnimation()` method of `Builder` is used to set Animation to the dialog.\n\nPrototype:\n\u003e setAnimation(String fileName)\n\n**Only** file name ***with extensions*** should passed to method.\n```java\n        MaterialButton mDialog = new MaterialDialog.Builder(this)\n                // Other Methods to create Dialog........               \n                .setAnimation(\"delete_anim.json\")               \n                //...\n```\n\n\u003ca name=\"getLottieAnimationView\"\u003e\u003c/a\u003e\n#### iii. Getting `LottieAnimationView` \nTo get `View` of Animation for any operations, there is a method in Material Dialogs which returns `LottieAnimationView` of dialog.\n```java\n        // Get Animation View\n        LottieAnimationView animationView = mDialog.getAnimationView();\n        // Do operations on animationView\n```\n\n\u003ca name=\"stateCallbacks\"\u003e\u003c/a\u003e\n### Dialog State Listeners \nThere are three callback events and listeners for Dialog.\n\nFollowing are interfaces for implementations:\n- `OnShowListener()` - Listens for dialog Show event. Its `onShow()` is invoked when dialog is displayed.\n- `OnCancelListener()` - Listens for dialog Cancel event. Its `onCancel()` is invoked when dialog is cancelled.\n- `OnDismissListener()` - Listens for dialog Dismiss event. Its `onDismiss()` is dismiss when dialog is dismissed.\n```java\n       ... \n       mDialog.setOnShowListener(this);\n       mDialog.setOnCancelListener(this);\n       mDialog.setOnDismissListener(this);\n    }\n    \n    @Override\n    public void onShow(DialogInterface dialogInterface) {\n        // Dialog is Displayed\n    }\n\n    @Override\n    public void onCancel(DialogInterface dialogInterface) {\n        // Dialog is Cancelled\n    }\n\n    @Override\n    public void onDismiss(DialogInterface dialogInterface) {\n        // Dialog is Dismissed\n    }\n}\n```\n\n\u003ca name=\"contribute\"\u003e\u003c/a\u003e\n## Contribute\nLet's develop with collaborations. We would love to have contributions by raising issues and opening PRs. Filing an issue before PR is must.\nSee [Contributing Guidelines](CONTRIBUTING.md). \n\n\u003ca name=\"credits\"\u003e\u003c/a\u003e\n## Credits\nThis library is built using following open-source libraries.\n- [Material Components for Android](https://github.com/material-components/material-components-android)\n- [Lottie for Android](https://github.com/airbnb/lottie-android)\n\n## License\nProject is published under the Apache 2.0 license. Feel free to clone and modify repo as you want, but don't forget to add reference to authors :)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatilshreyas%2Fmaterialdialog-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatilshreyas%2Fmaterialdialog-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatilshreyas%2Fmaterialdialog-android/lists"}