简体   繁体   English

在 Dialog 中放置一个 lottie 动画。 安卓

[英]Put a lottie animation in a Dialog. Android

I'm developing an app in android, and I want to use lottie for a Dialog that could have an animated icon of checked-done or fail.我正在 android 中开发一个应用程序,我想将 lottie 用于一个对话框,该对话框可能具有已检查完成或失败的动画图标。 Wellcome some examples or ideas. Wellcome 一些例子或想法。 I guess this is possible.我想这是可能的。 Thanks谢谢

You can do that using the LottieDialog library你可以使用 LottieDialog 库来做到这一点

Github Repo for examples and documentation : LottieDialog Github Repo 示例和文档: LottieDialog

Code example:代码示例:

Button button = new Button(this);
button.setText("Ok");
button.setTextColor(Color.WHITE);
button.setAllCaps(false);
int greenColor = ContextCompat.getColor(this, R.color.green);
button.setBackgroundTintList(ColorStateList.valueOf(greenColor));

LottieDialog dialog = new LottieDialog(this)
        .setAnimation(R.raw.success_like)
        .setAnimationRepeatCount(LottieDialog.INFINITE)
        .setAutoPlayAnimation(true)
        .setDialogBackground(Color.WHITE)
        .setMessage("Task is Done :D")
        .setMessageColor(greenColor)
        .addActionButton(button);

dialog.show();

You can add more buttons, or create it with no buttons,您可以添加更多按钮,或创建没有按钮的按钮,

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM