抽奖动画没有结束。怎么修?

时间:2019-04-10 10:24:59

标签: animation android-animation lottie lottie-android

我有这样的抽奖动画

https://dropmefiles.com/uweF8

您可以在Lottie预览网站上查看它

https://lottiefiles.com/preview

在预览中,此文件运行良好

但是如果您尝试将这种动画添加到这样的项目中

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.airbnb.lottie.LottieAnimationView
    android:id="@+id/animation_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:lottie_autoPlay="true"
    app:lottie_loop="false"
    app:lottie_rawRes="@raw/heart"
    app:lottie_scale="1.2"
    tools:background="@color/black_30_alpha"
    tools:layout_height="200dp"
    tools:layout_width="match_parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

所以您将得到这样的结果

введите сюда описание изображения

您会看到动画没有结束。

我在做什么错了?

我试图在代码中添加这样的行

mAnimHeart.setMaxProgress(1f);

但结果相同

2 个答案:

答案 0 :(得分:0)

在官方Lottie app中,此json文件的最后一帧与您的相同。因此该文件似乎有问题。也许Lottie团队并未在Android上添加对某些功能的支持。也许这只是错误。您可以在github repository上打开问题。

enter image description here

答案 1 :(得分:0)

此问题已在Lottie 3.0中修复 https://github.com/airbnb/lottie-android/issues/1034