依赖Lottie 后
compile 'com.airbnb.android:lottie:2.0.0-beta4'
添加LottieAnimationView控件
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animation_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="EmptyState.json"
app:lottie_loop="true"
app:lottie_autoPlay="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
运行后,发现报错
Caused by: android.view.InflateException: Binary XML file line #14: Binary XML file line #14: Error inflating class com.airbnb.lottie.LottieAnimationView
Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class com.airbnb.lottie.LottieAnimationView
Caused by: java.lang.reflect.InvocationTargetException
这是因为没有创建assets,用来存储animated JSON files 。需要在 app/src/main/assets 这个路径下创建assets文件夹
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)