openHarmony arkTs 表格中过长文字的滚动显示,类似LED屏的滚动显示效果

受限于开发板设备上的系统版本,只能使用API8

 Text(item.state)
                  .offset({
                    x: this.offsetX
                  })
                  .commonTdTextStyle()
                  .fontColor(GetColor(index))
                  .width(200)
                  .onAppear(() => {
                    animateTo({
                      duration: 5000,
                      curve: Curve.Linear,
                      delay: 500,
                      iterations: -1, // 设置-1表示动画无限循环
                      playMode: PlayMode.Alternate,
                      onFinish: () => {

                      }
                    }, () => {
                      this.offsetX = -200
                    })
                  })

我的想法是让文字通过动画接口animateTo方法移动,但是这个Text控件是浮动在整个表格上的。

求助如何解决这个问题

OpenHarmony
定制开发
2023-11-23 15:54:13
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Richarde

跑马灯效果可使用marquee组件,具体使用可参考以下地址:​​https://developer.harmonyos.com/cn/docs/documentation/doc-references/ts-basic-components-marquee-0000001333720945​


分享
微博
QQ
微信
回复
2023-11-24 11:20:05
提问
该提问已有0人参与 ,帮助了0人