MaterialStyledDialogs - 基于Material带头部的Android对话框
jopen
9年前
MaterialStyledDialogs - 一个Android库用于创建一个漂亮和可定制基于Material带头部的对话框。基于 material-dialogs 并且受到 dribbble 启发
How to include
Add the repository to your project build.gradle:
repositories { maven { url "https://jitpack.io" } }
And add the library to your module build.gradle:
dependencies { compile 'com.github.javiersantos:MaterialStyledDialogs:1.2' }
Usage
Basic Dialog
A basic dialog will show the provided title (optional) and description, using your primary color as the header background.
new MaterialStyledDialog(this) .setTitle("Awesome!") .setDescription("What can we improve? Your feedback is always welcome.") .show();
or using the builder...
MaterialStyledDialog dialog = new MaterialStyledDialog(this) .setTitle("Awesome!") .setDescription("What can we improve? Your feedback is always welcome.") .build(); ... dialog.show();
Customization
// Set an icon for the dialog header. .setIcon(R.drawable.ic_launcher)
// Set if the header icon will be displayed with an initial animation. // Default: true .withIconAnimation(false)
// Set if the dialog will be displayed with an open and close animation, with custom duration. // Default: false .withDialogAnimation(true) // Default: false, Duration.NORMAL .withDialogAnimation(true, Duration.SLOW)
// Set a color for the dialog header. // Default: Theme primary color. .setHeaderColor(R.color.dialog_header)
// Set an image for the dialog header. // API 16+ required. .setHeaderDrawable(R.drawable.header)
// Set if the dialog will be hidden when touching outside. // Default: true .setCancelable(false)
// Set if the description will be scrollable, with custom maximum lines. // Default: false .setScrollable(true) // Default: false, 5 .setScrollable(true, 10)
// Set a positive, negative and/or neutral button for the dialog. .setPositive(getResources().getString(R.string.button), new MaterialDialog.SingleButtonCallback() { @Override public void onClick(MaterialDialog dialog, DialogAction which) { Log.d("MaterialStyledDialogs", "Do something!"); } }) //.setNegative(...) //.setNeutral(...)
Apps already using this library
项目地址: https://github.com/javiersantos/MaterialStyledDialogs