LottieDialog
Android Library to create Lottie animation view dialog easily with a lot of customization
Why you should use Lottie Dialog
- You have no limited type of dialog, you create your own types and using them.
- You don't need to add unused file in your project, just add what you will use.
- You can add any number of buttons and customize them as you want.
- Customize dialog title as you want, change color, size and visibility.
- Customize dialog message as you want, change color, size and visibility.
- You can change your dialog width and height by number of by percentage.
- You can change the animation view width and height.
- Set your animation easily from assets, raw resources or URLs.
- And more...
Download or create Lottie animation file
- You can find many files and customize them from the Lottie offical website LottieFiles.com
- You can create your own lottie file from scratch, check Lottie Plugins LottieFiles.com/Plugins
Add Lottie Dialog to your project
From Maven Central
implementation 'io.github.amrdeveloper:lottiedialog:1.0.0'
Or Add LottieDialog from Jitpack.io
Add it in your root build.gradle at the end of repositories
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add the dependency
implementation 'com.github.amrdeveloper:lottiedialog:1.0.0'
And sync the Gradle.
Code Example
Button okButton = new Button(this);
okButton.setText("Ok");
okButton.setOnClickListener(view -> {});
Button cancelButton = new Button(this);
cancelButton.setText("Cancel");
cancelButton.setOnClickListener(view -> {});
LottieDialog dialog = new LottieDialog(this)
.setAnimation(R.raw.animation)
.setAnimationRepeatCount(LottieDrawable.INFINITE)
.setAutoPlayAnimation(true)
.setTitle("Title")
.setTitleColor(Color.WHITE)
.setMessage("Message...")
.setMessageColor(Color.WHITE)
.setDialogBackground(Color.BLACK)
.setCancelable(false)
.addActionButton(okButton)
.addActionButton(cancelButton)
.setOnShowListener(dialogInterface -> {})
.setOnDismissListener(dialogInterface -> {})
.setOnCancelListener(dialogInterface -> {});
dialog.show();
Documentation
Lottie Dialog was designed with a fluent interface concept and with the goal to make it customizable as much as we can
Set dialog title.
setTitle(String title);
Set dialog title color.
setTitleColor(int color)
Set dialog title text size.
setTitleTextSize(float size)
Set dialog title visibility, the default value is View.VISIBLE
.
setTitleVisibility(int visibility)
Set dialog message.
setMessage(String message)
Set dialog message text size.
setMessageTextSize(float size)
Set message visibility, the default value is View.VISIBLE
.
setMessageVisibility(int visibility)
Set dialog background color.
setDialogBackground(int color)
Set dialog background drawable.
setDialogBackgroundDrawable(Drawable drawable)
Set dialog dim amount.
setDialogDimAmount(float amount)
Set dialog cancelable.
setCancelable(boolean cancelable)
Set dialog canceled on touch outside.
setCanceledOnTouchOutside(boolean cancel)
Set dialog height.
setDialogHeight(int height)
Set dialog width.
setDialogWidth(int width)
Set dialog height by percentage, for example 0.50f
for 50%
.
setDialogHeightPercentage(float percentage)
Set dialog width by percentage, for example 0.50f
for 50%
.
setDialogWidthPercentage(float percentage)
Set Lottie animation view height.
setAnimationViewHeight(int height)
Set Lottie animation view width.
setAnimationViewWidth(int width)
Set animation from raw resources.
setAnimation(@RawRes int rawRes)
Set animation from Animation object.
setAnimation(Animation animation)
Set animation from assets folder
setAnimation(String assetName)
Set animation from URL, need INTERNET
permission
setAnimationFromUrl(String url)
Set repeat count for the animation, for indefinitely use LottieDialog.INFINITE
setAnimationRepeatCount(int count)
Set animation speed
setAnimationSpeed(float speed)
Add action button, you should set listeners and customize it then add it to Lottie dialog
addActionButton(Button button)
Add action button with the index
addActionButton(Button button, int index)
Control auto play animation when the dialog is showing
setAutoPlayAnimation(boolean autoplay)
Check animation auto playing value
isAutoPlayedAnimation()
Play the animation.
playAnimation()
Pause the animation.
pauseAnimation()
cancel the animation.
cancelAnimation()
clear the animation.
clearAnimation()
reverse the animation speed.
reverseAnimationSpeed()
Check if is animating or not.
isAnimating()
Show Lottie dialog.
show()
Check if Lottie dialog is showing.
isShowinng()
Dismiss Lottie dialog.
dismiss()
Cancel Lottie dialog`.
cancel()
Listen when Lottie dialog is showing.
setOnShowListener(DialogInterface.OnShowListener listener)
Listen when Lottie dialog is canceled.
setOnCancelListener(DialogInterface.OnCancelListener listener)
Listen when Lottie dialog is dismissed.
setOnDismissListener(DialogInterface.OnDismissListener listener)
How to contribute
- You are most welcome to request features, report bugs by creating a new issues.
- Before starting implementing the feature please make sure the issue is approved and assigned to you.