Lootie入门小结

来源:互联网 发布:linux 隐藏文件 编辑:程序博客网 时间:2024/06/03 22:57

开始用lottie是因为UX提出的新需求,要求加一个动效,于是辛辛苦苦写了个动效,然后拿着动效去找IOS同事去修改的时候,同事告诉我,用lottie。。。看了网上一些使用方法,自己开始跟着研究了一下,很简单。这里针对android简单说一下用法。

在XML中添加

<com.airbnb.lottie.LottieAnimationView    android:id="@+id/loading_restart_view"    android:layout_width="80dp"    android:layout_height="33dp"    android:layout_below="@+id/restart_message"    android:layout_centerHorizontal="true"    android:layout_marginTop="14dp"    android:background="@drawable/continue_btn_bg_line"    android:duplicateParentState="true"    android:gravity="center_vertical"    app:lottie_autoPlay="true"    app:lottie_fileName="simple_loader.json"    app:lottie_loop="true" />lo



lottie_autoPlay用来设置是否自动播放动效,默认值为false

lottie_filename为UX给的json文件名,json文件放在app/src/main/assets文件夹下

在代码就可以直接调用啦

最后,这个库的开源地址在这里:

Android: https://github.com/airbnb/lottie-android

iOS: https://github.com/airbnb/lottie-ios

ReactNative: https://github.com/airbnb/lottie-react-native