Json实现GIF
准备:
1.Json文件(AE生成);
2.添加依赖:compile 'com.airbnb.android:lottie:1.5.1'
实现:
1.布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
tools:context="com.anfly.animation.MainActivity">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottie_animationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:lottie_autoPlay="true"
app:lottie_fileName="data.json"
app:lottie_loop="true" />
</LinearLayout>
2.oncreate方法中:
setContentView(R.layout.activity_main);
lottie_animationView = findViewById(R.id.lottie_animationView);
lottie_animationView.loop(true);
参考:
https://blog.csdn.net/jhl122/article/details/56665374/
https://www.jianshu.com/p/cae606f45c0b
这篇博客介绍了如何通过Json文件和特定的依赖来实现GIF动态图的创建。首先,你需要一个由Adobe After Effects生成的Json文件,然后在项目中添加必要的依赖。接着,在布局文件和onCreate方法中进行相应设置。参考了CSDN和简书上的相关教程。
1826

被折叠的 条评论
为什么被折叠?



