android SmartRefreshLayout自定义刷新头、结合Lottie!(笔记)

本文介绍如何结合SmartRefreshLayout刷新框架与Lottie动画库来创建自定义的刷新头动画效果。文中提供了从添加依赖到具体实现步骤的详细代码示例。

引言:仅作为笔记、demo来源于SmartRefreshLayout 官网、稍作修改、引用地址:SmartRefreshLayout/md_custom.md at master · scwang90/SmartRefreshLayout · GitHub

这里使用 SmartRefreshLayout、以及Lottie两个库(Lottie也可以用svga替换);

先看效果吧!

解释:很简单、上面的动画是个json文件、这个文件被Lottie解析播放就行了、其他按照 SmartRefreshLayout 官网自定义header写就行!

废话不多说、粘出关键代码及目录结构;

1、添加依赖:


     // SmartRefreshLayout 刷新框架
    implementation 'io.github.scwang90:refresh-layout-kernel:2.0.5'
    //Lottie
    implementation "com.airbnb.android:lottie:5.2.0"

2、布局文件:

 activity_main.xml 代码:

<?xml version="1.0" encoding="utf-8"?>
<com.scwang.smart.refresh.layout.SmartRefreshLayout
    android:id="@+id/srl"
    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:background="@android:color/darker_gray"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:co
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值