实现思路如下:
@Entry
@Component
struct ScaleAnimationExample {
@State length: Length = 0;
@State scaleSize: number = 1;
build() {
Column() {
Row() {
Column() {
Text('我是文本1')
Text('我是文本2')
}
.height(this.length === 0 ? 'auto' : this.length)
Column() {
Text('我是文本1')
Text('我是文本2')
Text('我是文本3')
Text('我是文本4')
}
.height(this.length === 0 ? 'auto' : this.length)
Column() {
Text('我是文本1')
Text('我是文本2')
Text('我是文本3')
}
.height(this.length === 0 ? 'auto' : this.length)
}
.margin(16)
.alignItems(VerticalAlign.Top)
.scale({ x: this.scaleSize, y: this.scaleSize })
.onAppear(() => {
this.getUIContext().animateTo({
iterations: -1,
playMode: PlayMode.Alternate
}, () => {
this.scaleSize = 1.3;
});
})
}
.width('91%')
.margin(16)
.backgroundColor('#f3f5f7')
.borderWidth(3)
.borderRadius(36)
.borderColor(Color.White)
.justifyContent(FlexAlign.Center)
.alignItems(HorizontalAlign.Center)
}
}