介绍
本示例介绍使用显式动画 animateTo 实现左右地址交换动画。该场景多用于机票、火车票购买等出行类订票软件中。
效果预览图
使用说明
- 加载完成后显示地址交换动画页面,点击中间的图标,左右两边地址交换。
实现思路
- 创建左右两边Text组件显示地址。设置初始偏移量以及文本对齐方式。
Row() {
Text($r('app.string.address_exchange_address_left'))
.translate({ x: this.translateX })
.width($r('app.string.address_exchange_address_width'))
.textAlign(this.swap ? TextAlign.End : TextAlign.Start)
...
Text($r('app.string.address_exchange_address_right'))
.translate({ x: -this.translateX })
.width($r('app.string.address_exchange_address_width'))
.textAlign(this.swap ? TextAlign.Start : TextAlign.End)
...
}
- 点击中间的图标时,修改是