Json实现GIF

这篇博客介绍了如何通过Json文件和特定的依赖来实现GIF动态图的创建。首先,你需要一个由Adobe After Effects生成的Json文件,然后在项目中添加必要的依赖。接着,在布局文件和onCreate方法中进行相应设置。参考了CSDN和简书上的相关教程。

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值