中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
微信扫码分享
import app, { AppResponse } from '@system.app' @Entry @Component export struct Index { @State private arr: number[] = [0, 1, 2, 3, 4, 5, 6] @State dragItem: number = -1 @State scaleItem: number = -1 @State neighborItem: number = -1 @State neighborScale: number = -1 private dragRefOffset: number = 0 @State offsetY: number = 0 private ITEM_INTV: number = 120 aboutToAppear(): void { app.setImageRawDataCacheSize(1024*1024*100);//缓存 解码前数据上限,单位为字节;约等于9.53M app.setImageCacheCount(100);//设置内存中缓存解码后图片的数量上限 } build() { List() { ForEach(this.arr, (item: number, index: number) => { ListItem() { this.buildItem(item) } }, (item: number) => item.toString()) } .onClick(() => { let data = this.arr.splice(4, 1)[0] this.arr.splice(3, 0, data) }) } @Builder buildItem(item: number) { Row() { Image($r('app.media.app_icon')) .width(18) .height(18).syncLoad(true).syncLoad(true) Text('你好你好' + item) .fontSize(16) .fontWeight(FontWeight.Medium) .fontColor('#323232') .margin({ left: 12 }) Blank() Row() { Image($r('app.media.app_icon')) .height(18) .width(18) .autoResize(true).syncLoad(true) } .width(30) .height('100%') .alignItems(VerticalAlign.Center) .justifyContent(FlexAlign.Center) Row() { Image($r('app.media.app_icon')) .height(25) .width(25) .autoResize(true) } .height('100%') .width(50) .margin({ left: 30 }) .justifyContent(FlexAlign.End) .alignItems(VerticalAlign.Center) } .padding({left: 15, right: 15}) .width('100%') .height(50) .animation({ curve: Curve.Sharp, duration: 300 }) .backgroundColor(0xFFFFFF) .justifyContent(FlexAlign.SpaceBetween) } }