Lottie一个可轻松实现各种动画(SVG、Animations)的开源项目
来源:互联网 发布:大数据架构师年龄要求 编辑:程序博客网 时间:2024/05/18 02:50
先看一下官网给的图片:
相信肯定不少小伙伴还在为svg,Animations而头疼吗!Lottie这个开源项目的出现,真是久旱逢甘霖(个人感觉)。
有些人会认为这些即使不用这也可以实现啊!的确能实现,Android 5.x 之后提供了对 SVG 的支持,通过 VectorDrawable、AnimatedVectorDrawable 的结合可以实现一些稍微复杂的动画,可是这样你需要考虑很多:
- 写一堆代码来实现它
- 流畅度也要考虑
- 兼容性
- 要是公司要andorid和ios实现一套一模一样的,那资源的占用就显得过大了。
如果用Lottie这些都不需要考虑了,Lottie是支持Android、ios、ReactNative的,使用的过程也是很简单的。
总之Lottie这个项目,让我耳目一新,真是感觉吊的一笔!下面看看怎么简单使用的:
先看效果图:
- Lottie引用
compile 'com.airbnb.android:lottie:1.0.1'
- sdk最低要求: minSdkVersion 16
- xml配置
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="zlg.wolf.wolf_lottie.MainActivity"> <com.airbnb.lottie.LottieAnimationView android:id="@+id/animation_view" android:layout_width="wrap_content" android:layout_height="wrap_content" app:lottie_fileName="LottieLogo2.json" app:lottie_loop="true" app:lottie_autoPlay="true" /></RelativeLayout>
也可以在activity中这样写:
/** app:lottie_fileName="LottieLogo2.json" * app:lottie_loop="true" */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LottieAnimationView animationView = (LottieAnimationView) findViewById(R.id.animation_view); animationView.setAnimation("LottieLogo2.json"); animationView.loop(true); }
assets资源文件
这样就完成了!
本文主要是先讲述这个项目的简单使用,后续会继续学习其它的功能!Lottie资源库
Android: https://github.com/airbnb/lottie-android
iOS: https://github.com/airbnb/lottie-ios
ReactNative: https://github.com/airbnb/lottie-react-native
0 0
- Lottie一个可轻松实现各种动画(SVG、Animations)的开源项目
- Airbnb的开源项目Lottie简易实现动画
- Android SVG和Lottie库播放动画(Json)
- 开源项目- Lottie 简介
- 开源项目- Lottie 简介
- android Tween Animations(动画效果-代码实现)的使用
- Lottie开源动画库使用教程
- Lottie for Android 开源动画
- airbnb开源动画库lottie
- 开源项目Lottie的基本介绍(一)
- Lottie,一个强大的移动端动画库
- 推荐一个开源库(Calligraphy)将ttf字体库加入到项目中,轻松实现各种字体
- 开源项目- Lottie 源码分析
- svg engine 一个处理矢量图片的开源项目
- android动画效果之Animations(代码实现动画)
- 一个javabean轻松实现对数据库的各种操作
- 一个javabean轻松实现对数据库的各种操作
- 一个javabean轻松实现对数据库的各种操作
- java nio socket实例
- gperftools的使用
- 从自联想神经网络到深度神经网络
- 为什么上传文件的表单里要加个属性enctype
- http客户端请求
- Lottie一个可轻松实现各种动画(SVG、Animations)的开源项目
- jeesite快速开发平台(三)----项目文件结构与配置文件详解
- 线段树常用模板(转)
- TPS61042带PWM亮度调节的恒流LED驱动
- Android Studio配置正式签名和debug签名
- 《Android群英传》读书笔记4.ListView使用技巧
- muduo库的源代码分析2--简化方案
- MyBatis 源码分析——SqlSession接口和Executor类
- 数据库中varchar和Nvarchar区别与联系