【OpenHarmony】 鸿蒙 UI动画开发之recyclerview_animators

简介

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

下载安装

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

使用说明

  1. 引入组件库
javascript 复制代码
import { RecyclerView } from "@ohos/recyclerview-animators"
  1. 在代码中使用
scss 复制代码
@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)
  }

DD一下: 鸿蒙开发各类文档,可关注公众号<程序猿百晓生>获取。

erlang 复制代码
1.OpenHarmony开发基础
2.OpenHarmony北向开发环境搭建
3.鸿蒙南向开发环境的搭建
4.鸿蒙生态应用开发白皮书V2.0 & V3.0
5.鸿蒙开发面试真题(含参考答案) 
6.TypeScript入门学习手册
7.OpenHarmony 经典面试题(含参考答案)
8.OpenHarmony设备开发入门【最新版】
9.沉浸式剖析OpenHarmony源代码
10.系统定制指南
11.【OpenHarmony】Uboot 驱动加载流程
12.OpenHarmony构建系统--GN与子系统、部件、模块详解
13.ohos开机init启动流程
14.鸿蒙版性能优化指南
.......

接口说明

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

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

约束与限制

在下述版本验证通过:

  • DevEco Studio NEXT Developer Beta3: 5.0(5.0.3.530)
  • SDK: API12 (5.0.0.35(SP3))

目录结构

lua 复制代码
|---- recyclerview_animators  
|     |---- entry  # 示例代码文件夹
|     |---- library  # 库文件夹
|	    |----src
          |----main
              |----ets
                  |----components
                      |----adapterAnimator #动画效果适配
                      |----itemAnimator #元素动画效果实现
                      |----RecyclerView.ets #核心类
|           |---- Index.ets  # 对外接口
|     |---- README.md  # 安装使用方法                    
相关推荐
前端不太难1 小时前
如何设计 AI Native 鸿蒙应用架构
人工智能·架构·harmonyos
弓.长.1 小时前
ReactNative for OpenHarmony项目鸿蒙化三方库:@react-native-picker
react native·react.js·harmonyos
恋猫de小郭1 小时前
Android 禁止侧载将正式实施,需要等待 24 小时冷静期
android·flutter·harmonyos
ShuiShenHuoLe2 小时前
组件的状态ComponentV2
harmonyos·鸿蒙
弓.长.2 小时前
ReactNative for OpenHarmony项目鸿蒙化三方库:react-native-button — 自定义按钮组件
react native·react.js·harmonyos
坚果派·白晓明2 小时前
在 macOS 中搭建鸿蒙 PC 三方库交叉编译开发环境
macos·华为·harmonyos
枫叶丹42 小时前
【HarmonyOS 6.0】使用PAC脚本灵活管理网络连接
开发语言·网络安全·华为·信息与通信·harmonyos
longlongValue3 小时前
鸿蒙静态资源HAR开发日志
harmonyos·har·静态资源·har开发
心中有国也有家16 小时前
ArkTS 鸿蒙开发语法完全指南:从入门到实战
华为·harmonyos
Georgewu19 小时前
如何判断应用在鸿蒙卓易通或者出境易环境下?
android·harmonyos