鸿蒙os开发-------跑马灯 marquee的使用

效果图:

复制代码
@Component
export  struct MarqueeScroll{
  private  marqueeText: string = ''



  build() {
    Column() {
      Flex({ alignItems: ItemAlign.Center}) {
        Image($r('app.media.ic_new_ticker'))
          .width(20)
          .height(20)
          .margin({left:15,right:10})
        Marquee({
          src:this.marqueeText,
          start:true, //开始
          step:6, //速度,默认6
          loop:-1, //6循环次数,-1循环滚动
        })
          .margin({right:15})
          .fontColor($r('app.color.color_54ABFD'))
          .fontSize(13)
            //开始
          .onStart(() => {
            console.info('Marquee onStart')
          })
            //文本播放一次结束
          .onBounce(() => {
            console.info('Marquee onBounce')
          })
            //完成
          .onFinish(() => {
            console.info('Marquee onFinish')
          })
      }
      //设置父组件的宽度小于文本宽度
      .width('90%')
      .height(40)
      .backgroundColor($r('app.color.white'))
      .borderRadius(16)
    }
    .width('100%')
    .height(40)
  }
}
相关推荐
光影少年2 分钟前
对typescript开发框架的理解?
前端·javascript·typescript
Swift社区2 分钟前
Store + System:鸿蒙游戏黄金分层
游戏·华为·harmonyos
_waylau8 分钟前
历时三年《鸿蒙系统(HarmonyOS)移动开发实战》简介
华为·harmonyos·鸿蒙·鸿蒙系统
想你依然心痛9 分钟前
HarmonyOS 6(API 23)实战:打造“空间相册“——基于 Face AR 表情驱动 + 沉浸光感悬浮导航的 PC 端沉浸式照片浏览系统
华为·ar·harmonyos·悬浮导航·沉浸光感
maaath10 分钟前
【maaath】 Flutter for OpenHarmony 快捷工具箱应用实战开发
flutter·华为·harmonyos
a11177613 分钟前
“像风之翼“无人机巡检平台仪表盘
前端·javascript·开源·html·无人机
maaath16 分钟前
【maaath】Flutter for OpenHarmony 实战:茶叶茶艺应用开发详解
flutter·华为·harmonyos
maaath28 分钟前
【maaath】Flutter for OpenHarmony 的手办展示应用开发实践
flutter·华为·harmonyos
We་ct6 小时前
LeetCode 5. 最长回文子串:DP + 中心扩展
前端·javascript·算法·leetcode·typescript
Math_teacher_fan13 小时前
Flutter 跨平台开发实战:鸿蒙与音乐律动艺术(六)、Lissajous 利萨茹曲线:频率耦合的轨迹艺术
flutter·ui·数学建模·华为·harmonyos·鸿蒙系统