Android 使用LottieAnimationView 做启动动画

2023-05-16

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".ui.activity.SplashActivity">

    <com.airbnb.lottie.LottieAnimationView
        android:id="@+id/animationView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:lottie_rawRes="@raw/flower"
        app:lottie_autoPlay="true"
        app:lottie_loop="true"/>

</RelativeLayout>

今天在项目中看到LottieAnimationView 做的APP启动动画,找了一下资料,学习了

Lottie开源库地址:一个集Android、Ios、React Native与Web平台

首先这个Json 文件是怎么做出来 的呢?

他是通过AE自动生成的,具体可以参考下面文章,关于AE讲的比较详细 AE制作json文件格式动画以及lottie开源库的使用_Android_jiang的博客-CSDN博客_json动画制作

JSON动画库可下载:Featured animations from our community

  1. 引入库
    compile 'com.airbnb.android:lottie:4.2.1'

2 .创建assets文件夹,将json文件放入其中。

3 . 在XML中引用控制

控件常用属性

      app:lottie_fileName="likeanim.json"  加载json的文件名
      app:lottie_loop="true"  是否循环播放
      app:lottie_autoPlay="true"  是否自动播放

JAVA代码控制:

LottieAnimationView lottieLike= (LottieAnimationView) findViewById(R.id.animation_view);
lottieLike.setAnimation("data.json");
lottieLike.loop(true);       
lottieLike.playAnimation();   //播放
        lottieLike.pauseAnimation();  //暂停
        lottieLike.cancelAnimation();  //取消
        lottieLike.getDuration();   //获取动画时长
        lottieLike.addAnimatorListener(new Animator.AnimatorListener() {  //添加动画监听
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {

            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android 使用LottieAnimationView 做启动动画 的相关文章

随机推荐

  • 重新build iso报错

    报错内容 The CD ROM drive contains a CD which cannot be used for installation xff0c Please insert a suitable CD to continue
  • 给Kylin iso中添加自定义rpm包

    前言 在日常产品交付中会有如下需求 xff1a 客户自己安装centos ubuntu kylin iso xff0c 然后我们把rpm包给到客户 我们直接将rpm包封装到iso xff0c 给客户交付整体iso xff0c 这样不管是对于
  • 适配Dell R750xs server Broadcom BCM57412 NetXtreme-E 10Gb SFP+ 网卡

    摘要 The Issue is to handle Scaler v8 2 385 baf7f3a on Dell R750xs server the 10G NIC card is Broadcom BCM57412 NetXtreme
  • Python3中的urllib.request模块

    Python 3 x版本后的urllib和urllib2 现在的Python已经出到了3 5 2 在Python 3以后的版本中 xff0c urllib2这个模块已经不单独存在 xff08 也就是说当你import urllib2时 xf
  • Python 正则re模块之findall()详解

    1 先说一下findall 函数的两种表示形式 import re kk 61 re compile r 39 d 43 39 kk findall 39 one1two2three3four4 39 1 2 3 4 注意此处findall
  • 用python实现将文件拷贝到指定目录

    基本方法 import os import shutil alllist 61 os listdir u 34 D notes python 资料 34 for i in alllist aa bb 61 i split 34 34 if
  • Ubuntu16.04忘记用户登录密码以及管理员密码,重置密码的解决方案

    1 问题现象 xff1a 由于自己想修改一下当前用户名 xff0c 结果乱改了部分配置文件导致登陆时 xff0c 原先的密码失效 2 问题原因 问题原因 xff0c 搞不懂 xff0c 只是修改了 etc shadow和 etc sudoe
  • 点赋科技:本地生活,如何开启复苏之路

    目前 xff0c 全球经历 这 场前所未有的疫情大流行 已经结束 xff0c 尽管 许多国家和地区的经济和社会都受到了影响 然而 xff0c 做好本地生活的复苏规划和推进 xff0c 将有助于在疫情之后尽快走出经济低迷期 xff0c 恢复社
  • 1130, "Host 'xxxx' is not allowed to connect to this MySQL server"

    问题描述 xff1a 1 在centos装好mysql后 xff0c 在python3程序中通过pymysql远程连接mysql xff0c 但是报 Host 39 39 not allowed connect错误 解决方法 xff1a 1
  • Pycharm配置Git教程

    1 使用场景 平时习惯在windows下开发 xff0c 但是我们又需要实时将远方仓库的代码clone到本地 xff0c 也许要将自己修改的代码push到远端服务器 xff0c 有很多方法可以实现这个需求 xff0c 但是所用的编辑软件不一
  • Ubuntu18.04安装NVIDIA驱动后,循环登录,登录界面进不去,输完密码又回到登录界面

    我安装的是Ubuntu18 04 5 xff0c 3090公版显卡 xff0c 在安装好驱动之后 xff0c 一直循环在登录界面 xff0c 输入密码之后一闪又回到登录界面 xff0c 重装了多次驱动还是不行 解决方法 xff1a 后来发现
  • 安装达梦数据库选择安装路径时提示“无写入权限”

    在使用中标麒麟的Linux系统虚拟机安装达梦数据库时 xff0c 遇到了选择安装路径时 xff0c 数据库安装程序报 无写入权限 问题 经过一番折腾后发现 xff0c 问题原因时系统的临时目录空间太小所导致的 解决方法 xff1a 1 重新
  • Docker部署MySQL单机版

    简单版 一 查看本机是否有MySQL及MySQL端口 防止端口占用 xff09 ps ef grep mysql 二 拉取MySQL镜像 docker pull mysql 5 7 三 运行MySQL镜像 docker run d p 33
  • win10无法关机解决方法

    win10无法关机怎么办 下面阐述一下处理的过程 1 左键双击控制面板 控制面板已放到桌面 xff0c 再单击电源选项 2 在打开的电源选项窗口 xff0c 左键点击 xff1a 选择电源按纽的功能 xff0c 打开系统设置 3 在系统设置
  • 小米电视访问电脑共享文件夹

    输入win 43 R打开运行窗口 输入control进入控制面板 点击 网络和internet 网络共享中心 更改高级共享设置 a 专用 网络设置如图 xff1a b 来宾或公用 网络设置如图 xff1a c 所有网络 设置如图 xff1a
  • 让Everything搜索结果更清爽

    Everything的文件搜索功能很强大 xff0c 但是默认设置下搜索出的结果过于丰富 xff0c 总是会有一些乱七八糟的后缀名文件 xff08 如下图 xff09 xff0c 或许我们并不想搜索出那些文件 这时我们需要对它设置里的排除列
  • 上机 Qt5.14.2 编程应用

    上机 Qt5 14 2 编程应用 关于QT Qt是一个1991年由Qt Company开发的跨平台C 43 43 图形用户界面应用程序开发框架 它既可以开发GUI程序 xff0c 也可用于开发非GUI程序 xff0c 比如控制台工具和服务器
  • Android Studio报错:Error:Could not find com.android.tools.build:gradle:4.1 记一次不长记性的坑

    本文地址 xff1a https blog csdn net zengsidou article details 79797417 看字面意思 xff0c 这个问题是Gradle没有对应版本 在搜索引擎没有找到方法之后 xff0c 尝试自己
  • VBox关闭dhcp

    VBox关闭dhcp C Program Files Oracle VirtualBox gt VBoxManage exe list dhcpservers NetworkName HostInterfaceNetworking Virt
  • Android 使用LottieAnimationView 做启动动画

    lt xml version 61 34 1 0 34 encoding 61 34 utf 8 34 gt lt RelativeLayout xmlns android 61 34 http schemas android com ap