想要在lottie动画中禁用循环

时间:2018-03-29 18:06:30

标签: react-native lottie bodymovin lottie-android

我想知道如何只运行一次Lottie动画,因为默认情况下它是循环的。 以下是我要修改的代码的链接:https://docs.expo.io/versions/latest/sdk/lottie.html

感谢。

3 个答案:

答案 0 :(得分:2)

您可以使用loop prop来设置组件的循环行为。有关您可以使用lottie的属性的更多信息,请访问here

 // A boolean flag indicating whether or not the animation should loop.
 loop: boolean = false,

答案 1 :(得分:1)

在Java中,禁用像这样的Lottie动画循环可能对此有所帮助:

首先,声明LottieAnimationView: "dependencies": { "@angular/animations": "5.2.11", "@angular/cdk": "^5.1.0", "@angular/common": "5.2.11", "@angular/compiler": "5.2.11", "@angular/compiler-cli": "5.2.11", "@angular/core": "5.2.11", "@angular/fire": "^5.2.1", "@angular/flex-layout": "^5.0.0-beta.15", "@angular/forms": "5.2.11", "@angular/http": "5.2.11", "@angular/platform-browser": "5.2.11", "@angular/platform-browser-dynamic": "5.2.11", "@ionic-native/core": "~4.11.0", "@ionic-native/splash-screen": "~4.11.0", "@ionic-native/status-bar": "~4.11.0", "@ionic/pro": "^2.0.3", "@ionic/storage": "^2.2.0", "@ngrx/effects": "^5.2.0", "@ngrx/store": "^5.2.0", "@ngrx/store-devtools": "^5.2.0", "@types/cordova": "0.0.34", "cordova-android": "^7.1.4", "cordova-browser": "^5.0.4", "cordova-ios": "^4.5.5", "cordova-plugin-device": "^2.0.2", "cordova-plugin-file": "^6.0.1", "cordova-plugin-file-transfer": "^1.7.1", "cordova-plugin-ionic": "^5.3.1", "cordova-plugin-ionic-keyboard": "^2.1.3", "cordova-plugin-ionic-webview": "^2.5.1", "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-statusbar": "^2.4.2", "cordova-plugin-whitelist": "^1.3.3", "firebase": "^6.2.4", "ionic-angular": "3.9.2", "ionic2-auto-complete": "^1.6.2-alpha", "ionicons": "3.0.0", "ng2-nvd3": "^2.0.0", "ngx-perfect-scrollbar": "^5.3.5", "rxjs": "6.2.0", "rxjs-compat": "6.2.0", "sw-toolbox": "3.6.0", "zone.js": "0.8.26" },

然后找到ID为LottieAnimationView myAnim; // //在这里查看v,因为它是片段工作,所以我使用它。

现在您可以使用布尔值更改循环选项:myAnim = v.findViewById(R.id.upload_anim);

答案 2 :(得分:1)

在 flutter 中,只需在资产后执行 repeat:false

像这样:

Lottie.asset('assets/lottie.json',repeat: false)