美文网首页
Lottie Android 动画初体验

Lottie Android 动画初体验

作者: jdallen | 来源:发表于2019-02-14 15:57 被阅读0次

1、准备动画的json文件
到lottiefiles这个网站下载你喜欢的动画

2、在main目录下新建assets目录,把导出的data.json文件放入其中。

3、在app module的build.gradle中加入依赖:(https://github.com/airbnb/lottie-android

compile 'com.airbnb.android:lottie:2.0.0-beta4'

4、在xml布局中写如下代码:

    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/animation_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

5、在Activity添加

LottieAnimationView animationView = (LottieAnimationView) view.
findViewById(R.id.animation_view);

animationView.setAnimation("data.json");
animationView.loop(true);
animationView.playAnimation();

相关文章

网友评论

      本文标题:Lottie Android 动画初体验

      本文链接:https://www.haomeiwen.com/subject/uglkqftx.html