当前位置:网站首页>自定义recycleView的删除&移动的动画
自定义recycleView的删除&移动的动画
2022-07-27 18:54:00 【Azadoo】
首先 RecycleView是有一套自己默认的动画、以及相应执行时机
但是在项目开发中,遇到了需要为删除item的动效进行调整
思路1. 可以在holder中(比如点删除的点击事件)直接为当前view设置自定义动画并执行
思路2. 重写recycleView默认动画 SimpleItemAnimator
简单的场景下思路1是可以达到预期效果的,但是个人在项目中遇到了另一个难题,ui给的动画需要在执行删除动画的同时 下方列表要同时上移。
但是recycleView默认的是删除动画执行完之后才去执行移动动画 这种情况下思路1就无法达到预期 只能重写SimpleItemAnimator了
好消息是recycleView自身已经封装好了一个默认DefaultItemAnimator该类中对抽象类SimpleItemAnimator所有方法都以重写实现 我们只要继承DefaultItemAnimator对需要调整的方法重写即可
坏消息是 内部没有能直接提供调用开始移动动画或删除动画的方法 有的是runPendingAnimations() 该方法内部设置了各个动画的执行实际 我们重写这个方法 几乎等同于需要重写整个类
源码如下
@Override
public void runPendingAnimations() {
boolean removalsPending = !mPendingRemovals.isEmpty();
boolean movesPending = !mPendingMoves.isEmpty();
boolean changesPending = !mPendingChanges.isEmpty();
boolean additionsPending = !mPendingAdditions.isEmpty();
// 判断是否有动画需要执行
if (!removal边栏推荐
- ADB shell LS /system/bin (index table)
- What is the value of digital factory management system
- 图解 SQL,这也太形象了吧!
- Verilog HDL中的reg型变量的理解
- What are the product performances of industrial Ethernet switches?
- 成分句法分析综述(第二版)
- 综合设计一个OPPE主页--页面的搜素欧珀部分的样式
- Dobot magician robot arm - Introduction
- Tips for file upload to bypass WAF
- LeetCode每日一练 —— 203. 移除链表元素
猜你喜欢

LeetCode每日一练 —— 21. 合并两个有序链表
![论文赏析[AAAI18]面向序列建模的元多任务学习](/img/2b/345b5a287fcd9c9b1a86ae683f124b.png)
论文赏析[AAAI18]面向序列建模的元多任务学习

Automatic classification of e-commerce UGC pictures using Baidu PaddlePaddle easydl

Unity installs personal free edition

The maximum recommended number of rows for MySQL is 2000W. Is it reliable?

Good driving, inexpensive, comfortable and safe! Experience BYD song Pro DM-I in depth

Leetcode daily practice - 876. Intermediate node of linked list

智能网联跑出中国「加速度」,26.15%搭载率背后的市场洗牌
![论文赏析[EMNLP18]用序列标注来进行成分句法分析](/img/99/98f3e5795407c764907e957f69df10.png)
论文赏析[EMNLP18]用序列标注来进行成分句法分析

Dobot magician robot arm - Introduction
随机推荐
How to make personalized recommendations instantly accessible? Cloud native database gaussdb (for redis) to help
LeetCode每日一练 —— 链表中倒数第 k 个结点
数字化工厂系统有什么现实优势
How to check the Bluetooth version of Bluetooth headset
LeetCode每日一练 —— 21. 合并两个有序链表
Sscanf caused the address to be out of bounds
14 day Hongmeng device development practice - Chapter 7 device networking cloud learning notes
Five celebrities' worries about AI
电脑微软账户登录一直转圈怎么解决问题
说明书丨Worthington逆转录酶、重组 HIV 检测方案
Thesis appreciation [emnlp18] uses sequence tagging for component parsing
大佬们,mysql版本低,不支持cdc,所以canal同步binlog至kafka,数据同步至cli
Using pseudo element before to realize equal scaling of elements
LeetCode每日一练 —— 206. 反转链表
论文赏析[AAAI18]面向序列建模的元多任务学习
MAPGIS 3D scene rendering technology and Application
30分钟彻底弄懂 synchronized 锁升级过程
Hexagon_ V65_ Programmers_ Reference_ Manual(7)
MySQL data recovery process is based on binlog redolog undo
多人协作开发规范