中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
本文原创发布在华为开发者社区。
该示例实现频道选择UI,通过Grid实现页面布局,实现长按拖动、删除等动画效果。
实现频道选择UI源码链接
进入应用,点击右上角的编辑按钮后,可以拖动item,并修改其顺序。可以点击图标右上角的删除按钮进行图标删除。
Button() { Text(this.isEdit ? "完成" : "编辑") .fontColor(this.isEdit ? Color.Black : 0xF9CF93) }.width(80) .height(30) .backgroundColor(Color.White) .onClick(() => { this.isEdit = !this.isEdit this.jumpWithSpeed(5) })
changeIndex(index1: number, index2: number) { this.numbers.splice(index2, 0, this.numbers.splice(index1, 1)[0]) }
if (this.isEdit) { Image($r('app.media.close')) .width(20) .height(20) .onClick(() => { animateTo({ duration: 300 }, () => { this.numbers.splice(index, 1) }) this.stopJump() this.jumpWithSpeed(5) }) }
微信扫码分享