{"id":13428357,"url":"https://github.com/javiersantos/MaterialStyledDialogs","last_synced_at":"2025-03-16T01:32:27.141Z","repository":{"id":49829136,"uuid":"51272475","full_name":"javiersantos/MaterialStyledDialogs","owner":"javiersantos","description":"A library that shows a beautiful and customizable Material-based dialog with header. API 14+ required.","archived":false,"fork":false,"pushed_at":"2020-09-02T19:15:01.000Z","size":5455,"stargazers_count":1174,"open_issues_count":28,"forks_count":155,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-10-12T20:03:40.338Z","etag":null,"topics":["android-library","animation","dialog","gradle","icons","material-design"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/javiersantos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-08T00:04:38.000Z","updated_at":"2024-09-25T08:55:34.000Z","dependencies_parsed_at":"2022-08-25T15:41:13.792Z","dependency_job_id":null,"html_url":"https://github.com/javiersantos/MaterialStyledDialogs","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiersantos%2FMaterialStyledDialogs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiersantos%2FMaterialStyledDialogs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiersantos%2FMaterialStyledDialogs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/javiersantos%2FMaterialStyledDialogs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/javiersantos","download_url":"https://codeload.github.com/javiersantos/MaterialStyledDialogs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221631911,"owners_count":16855020,"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-library","animation","dialog","gradle","icons","material-design"],"created_at":"2024-07-31T01:00:54.239Z","updated_at":"2024-10-27T05:30:58.656Z","avatar_url":"https://github.com/javiersantos.png","language":"Kotlin","funding_links":[],"categories":["Libraries","对话框"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eMaterialStyledDialogs \u003ca href=\"https://github.com/javiersantos/MaterialStyledDialogs#how-to-include\"\u003e\u003cimg src=\"https://jitpack.io/v/javiersantos/MaterialStyledDialogs.svg\"\u003e\u003c/a\u003e\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003eAndroid Library\u003c/h4\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca target=\"_blank\" href=\"https://android-arsenal.com/api?level=14\"\u003e\u003cimg src=\"https://img.shields.io/badge/API-14%2B-orange.svg\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"https://travis-ci.org/javiersantos/MaterialStyledDialogs\"\u003e\u003cimg src=\"https://travis-ci.org/javiersantos/MaterialStyledDialogs.svg?branch=master\"\u003e\u003c/a\u003e\n  \u003ca target=\"_blank\" href=\"http://android-arsenal.com/details/1/3136\"\u003e\u003cimg src=\"https://img.shields.io/badge/Android%20Arsenal-MaterialStyledDialogs-blue.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003eAndroid Library that shows a beautiful and customizable Material designed dialog with header. Based on \u003ca target=\"_blank\" href=\"https://github.com/afollestad/material-dialogs\"\u003ematerial-dialogs\u003c/a\u003e and inspired by this \u003ca target=\"_blank\" href=\"https://dribbble.com/shots/2439453-Sprocket-AND-1-3-3-OS-Consistent-Dialogs\"\u003edribbble\u003c/a\u003e.\u003c/p\u003e\n\n![MaterialStyledDialogs](https://raw.githubusercontent.com/javiersantos/MaterialStyledDialogs/master/Screenshots/banner.png)\n\n## How to include\nAdd the repository to your project **build.gradle**:\n```gradle\nrepositories {\n    jcenter()\n    maven {\n        url \"https://jitpack.io\"\n    }\n}\n```\n\nAnd add the library to your module **build.gradle**:\n\n**AndroidX**\n\n```gradle\ndependencies {\n    implementation 'com.github.javiersantos:MaterialStyledDialogs:3.0.1'\n}\n```\n\n**Pre AndroidX (no longer supported)**\n\n```gradle\ndependencies {\n    implementation 'com.github.javiersantos:MaterialStyledDialogs:2.2'\n}\n```\n\n## Usage\n### Basic Dialog\nA basic dialog will show the provided title (optional) and description, using your primary color as the header background. You have access to methods such as `setTitle()`, `setContent()`, `setIcon()`, `setCancelable()`, `dismiss()`, etc. Customizations are explained below.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.show();\n```\n\n\u003c/details\u003e\u003cbr\u003e\n\nor using the builder...\n\n```kotlin\nval dialog = MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.build()\ndialog.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nMaterialStyledDialog dialog = new MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.build();\n...\ndialog.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n## Customizations ([Wiki](https://github.com/javiersantos/MaterialStyledDialogs/wiki))\n### Setting a style\n\n\u003ctable align=\"center\"\u003e\n    \u003ctr\u003e\n        \u003cth\u003e\n            \u003cimg src=\"https://raw.githubusercontent.com/javiersantos/MaterialStyledDialogs/master/Screenshots/style-1.png\" height=\"400\" /\u003e\n        \u003c/td\u003e\n        \u003cth\u003e\n            \u003cimg src=\"https://raw.githubusercontent.com/javiersantos/MaterialStyledDialogs/master/Screenshots/style-2.png\" height=\"400\" /\u003e\n        \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n    \t\u003ctd\u003eHeader with Icon (default): .setStyle(Style.HEADER_WITH_ICON)\u003c/td\u003e\n    \t\u003ctd\u003eHeader with Title: .setStyle(Style.HEADER_WITH_TITLE)\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setStyle(Style.HEADER_WITH_ICON)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setStyle(Style.HEADER_WITH_ICON)\n\t//.setStyle(Style.HEADER_WITH_TITLE)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Displaying an icon\nThe dialog icon is displayed in the center of the dialog (as seen it the screenshots).\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setIcon(R.drawable.ic_launcher)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setIcon(R.drawable.ic_launcher)\n\t//.setIcon(ContextCompat.getDrawable(this, R.drawable.ic_launcher))\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Using a custom header color\nBy default, your primary color will be used for the header background. However you can customize this by adding:\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setHeaderColor(R.color.dialog_header)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setHeaderColor(R.color.dialog_header)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Using an image as the header background\nCustomize your dialog by adding a drawable instead of a color.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setHeaderDrawable(R.drawable.header)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setHeaderDrawable(R.drawable.header)\n\t//.setHeaderDrawable(ContextCompat.getDrawable(this, R.drawable.heaer))\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Adding a darker/grey overlay to the header background\nSome icons or drawables may fit better when using a darker/grey overlay. Using the `.withDarkerOverlay()` method the library will apply a color filter to the header background. `false` by default.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setHeaderDrawable(R.drawable.header)\n\t.withDarkerOverlay(true)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setHeaderDrawable(R.drawable.header)\n\t.withDarkerOverlay(true)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Adding icon and dialog animations\nAn animation to the icon will be displayed when the dialog is opened (`true` by default).\nYou can also add a custom animation using `.setIconAnimation(R.anim.your_animation)`. A zoom in-out animation will be used by default.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.withIconAnimation(true)\n\t.setIconAnimation(R.anim.your_animation)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.withIconAnimation(true)\n\t.setIconAnimation(R.anim.your_animation)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\nThe dialog will be displayed with an animation when it is opened and closed. `false` by default.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.withDialogAnimation(true)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.withDialogAnimation(true)\n\t//.withDialogAnimation(true, Duration.SLOW)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Adding buttons and callbacks\nButtons are showed at the end of the bottom dialog. You can add your own text and actions/callbacks.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setPositiveText(R.string.button)\n\t.onPositive { Log.d(\"MaterialStyledDialogs\", \"Do something!\"); }\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\t\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setPositiveText(R.string.button)\n\t.onPositive(new MaterialDialog.SingleButtonCallback() {\n\t\t@Override\n\t\tpublic void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {\n\t\t\tLog.d(\"MaterialStyledDialogs\", \"Do something!\");\n\t})\n\t//.setNegativeText(...)\n\t//.onNegative(...)\n\t//.setNeutralText(...)\n\t//.onNeutral(...)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\nIf no `onPositive(...)`, `onNegative(...)` or `onNeutral(...)` callbacks are provided, then the bottom dialog will be dismissed when tapping on the button.\n\nIf `autoDismiss()` is turned `false`, then you must manually dismiss the dialog in these callbacks. Auto dismiss is `true` by default.\n\nA divider before the buttons can be added using the `.withDivider(true)` method (`false` by default).\n\n#### Get the buttons of the dialog\nIf you need to access the buttons of your dialog, you can achieve it like this:\n```kotlin\nval dialog = MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"This is a sample description.\")\n\t.show()\n\ndialog.positiveButton().text = \"Positive\"\ndialog.negativeButton().text = \"Negative\"\n```\n\n### Dismissing when touching outside\nThe `setCancelable()` method lets you disable dismissing the bottom dialog when you tap outside the dialog window. `true` by default.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setCancelable(true)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setCancelable(true)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Adding a custom view\nYou can add custom view to your bottom dialog just by adding the layout to the `setCustomView()` method.\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setCustomView(your_custom_view)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"What can we improve? Your feedback is always welcome.\")\n\t.setCustomView(your_custom_view) // Old standard padding: .setCustomView(your_custom_view, 20, 20, 20, 0)\n\t//.setCustomView(your_custom_view, 10, 20, 10, 20) // int left, int top, int right, int bottom\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\nA detailed description is available at: https://github.com/javiersantos/MaterialStyledDialogs/wiki/Adding-a-custom-view\n\n### Making the content scrollable\nIf your dialog content is too long you may prefer to make it scrollable. By using the next method you can specify the minimum number of lines to show the scroll bar (`5 lines` by default).\n\n```kotlin\nMaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"A loooooooooong looooooooooong really loooooooooong content. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pulvinar sem nibh, et efficitur massa mattis eget. Phasellus condimentum ligula.\")\n\t.setScrollable(true)\n\t.show()\n```\n\n\u003cdetails\u003e\u003csummary\u003e\u003cb\u003eJava Sample\u003c/b\u003e\u003c/summary\u003e\n\n```Java\nnew MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"A loooooooooong looooooooooong really loooooooooong content. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pulvinar sem nibh, et efficitur massa mattis eget. Phasellus condimentum ligula.\")\n\t.setScrollable(true)\n\t//.setScrollable(true, 10)\n\t.show();\n```\n\t\n\u003c/details\u003e\u003cbr\u003e\n\n### Get the buttons of the dialog\nIf you need to access the buttons of your dialog, you can achieve it like this:\n```kotlin\nval dialog = MaterialStyledDialog.Builder(this)\n\t.setTitle(\"Awesome!\")\n\t.setDescription(\"This is a sample description.\")\n\t.show()\n\ndialog.positiveButton().text = \"Positive\"\ndialog.negativeButton().text = \"Negative\"\n```\n\n## License\n\tCopyright 2016-2020 Javier Santos\n\n\tLicensed under the Apache License, Version 2.0 (the \"License\");\n\tyou may not use this file except in compliance with the License.\n\tYou may obtain a copy of the License at\n\n\t   http://www.apache.org/licenses/LICENSE-2.0\n\n\tUnless required by applicable law or agreed to in writing, software\n\tdistributed under the License is distributed on an \"AS IS\" BASIS,\n\tWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\tSee the License for the specific language governing permissions and\n\tlimitations under the License.\n\n\tMaterialStyledDialogs includes code from material-dialogs, which is \n\tlicensed under the MIT license. You may obtain a copy at\n\t\n\t   https://github.com/afollestad/material-dialogs/blob/master/LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaviersantos%2FMaterialStyledDialogs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaviersantos%2FMaterialStyledDialogs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaviersantos%2FMaterialStyledDialogs/lists"}