OpenHarmony UI动画-recyclerview_animators

简介

带有添加删除动画效果以及整体动画效果的list组件库

下载安装

复制代码
ohpm install @ohos/recyclerview-animators

OpenHarmony ohpm 环境配置等更多内容,请参考如何安装OpenHarmony ohpm 包

使用说明

  1. 引入组件库

    import { RecyclerView } from "@ohos/recyclerview-animators"

  2. 在代码中使用

    @State controller: RecyclerView.Controller = new RecyclerView.Controller()
    private listDatas = ["A","B","C"]

    aboutToAppear() {
    this.controller.setAdapterAnimation(RecyclerView.AdapterAnimationType.AlphaIn) // 设置列表整体效果类型
    this.controller.setFirstOnly(false) // 设置是否在item重复出现时显示动画效果
    this.controller.setDuration(500) // 设置动画时长
    }

    build() {
    Column() {
    RecyclerView({
    array: this.listDatas, // 数据源
    controller: this.controller, // 控制器
    child: (itemData) => {
    this.SpecificChild(itemData) // 子布局
    }
    })
    }
    }

    @Builder SpecificChild(itemData) {
    Column() {
    Image($r("app.media.chip"))
    .width('100%')
    .height(100)
    Text(itemData + '')
    .fontSize(20)
    .textAlign(TextAlign.Center)
    .width('100%')
    }.margin(10)
    }

接口说明

controller: RecyclerView.Controller = new RecyclerView.Controller()

  1. 设置列表整体效果类型 this.controller.setAdapterAnimation()
  2. 设置是否在item重复出现时显示动画效果 this.controller.setFirstOnly()
  3. 设置动画时长 this.controller.setDuration()

约束与限制

在下述版本验证通过:

  • DevEco Studio 版本: 4.1 Canary(4.1.3.317)
  • OpenHarmony SDK: API11 (4.1.0.36)

目录结构

复制代码
|---- recyclerview_animators  
|     |---- entry  # 示例代码文件夹
|     |---- library  # 库文件夹
|	    |----src
          |----main
              |----ets
                  |----components
                      |----adapterAnimator #动画效果适配
                      |----itemAnimator #元素动画效果实现
                      |----RecyclerView.ets #核心类
|           |---- Index.ets  # 对外接口
|     |---- README.md  # 安装使用方法                    
```### 写在最后

**如果你觉得这篇内容对你还蛮有帮助,我想邀请你帮我三个小忙**:
*   点赞,转发,有你们的 『点赞和评论』,才是我创造的动力。
*   关注小编,同时可以期待后续文章ing🚀,不定期分享原创知识。
*   **想要获取更多完整鸿蒙最新学习资源,请移步前往小编:[`gitee.com/MNxiaona/733GH`](https://gitee.com/MNxiaona/733GH)**

![](https://i-blog.csdnimg.cn/direct/e9e45b82da9441889c6c17e0791831bc.jpeg#pic_center)
相关推荐
ZC跨境爬虫1 小时前
跟着 MDN 学 HTML day_13:多媒体嵌入 —— 视频与音频
前端·css·笔记·ui·html·音视频
ZC跨境爬虫21 小时前
跟着 MDN 学 HTML day_12:(HTML网页图片嵌入)
前端·javascript·css·ui·html
~央千澈~1 天前
《2026鸿蒙NEXT纯血开发与AI辅助》第六章:「微距」项目启动——工程创建与整体架构设计-卓伊凡
人工智能·harmony·鸿蒙开发·鸿蒙next·harmony os
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_11:(语义化容器全站重构+独立CSS拆分+字体合规引入)
前端·css·ui·重构·html·edge浏览器
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_10:(超链接核心语法+路径规则)
前端·css·笔记·ui·html·edge浏览器
ZC跨境爬虫1 天前
跟着 MDN 学 HTML day_9:(信件语义标记)
前端·css·笔记·ui·html
Avalon7122 天前
Unity3D响应式渲染UI框架UniVue
游戏·ui·unity·c#·游戏引擎
qq_454245032 天前
从 UI 操作到环境交互:一种通用元命令自动化协议的设计与意义
人工智能·ui·自动化·交互
格林威2 天前
工业视觉检测:提供可视化UI调试工具的实现方式是什么?
开发语言·人工智能·数码相机·ui·计算机视觉·视觉检测·工业相机
ZC跨境爬虫2 天前
跟着 MDN 学 HTML day_8:(高级文本语义标签+适配核心功底)
前端·css·笔记·ui·html