Progress的ScaleRing样式,如何实现loading效果

Progress的ScaleRing样式,如何实现loading效果

HarmonyOS
2024-04-29 00:17:52
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
gdycp

参考如下Demo:

@Entry 
@Component 
struct ProgressExample { 
  @State progressValue: number = 0 
  @State animationId: number | null = null 
  build() { 
    Column({ space: 15 }) { 
      Progress({ value: 0, total: 100, type: ProgressType.ScaleRing }) 
        .color(Color.Orange) 
        .value(this.progressValue) 
        .width(100) 
        .style({ strokeWidth: 10, scaleCount: 20, scaleWidth: 5, enableSmoothEffect: true }) 
      Progress({ value: 0, total: 100, type: ProgressType.ScaleRing }) 
        .color(Color.Red) 
        .value(this.progressValue) 
        .width(100) 
        .style({ strokeWidth: 10, scaleCount: 20, scaleWidth: 5, enableSmoothEffect: true }) 
      Button('开始动画').onClick(() => { 
        if (this.animationId === null) { 
          this.animationId = setInterval(() => { 
            this.progressValue++ 
            if (this.progressValue == 100) { 
              this.progressValue = 0 
            } 
          }, 10) 
        } 
        console.log(this.animationId.toString()) 
      }) 
      Button('结束动画').onClick(() => { 
        clearInterval(this.animationId) 
        this.animationId = null 
        this.progressValue = 0 
      }) 
    }.width('100%').padding({ top: 5 }) 
  } 
}
分享
微博
QQ
微信
回复
2024-04-29 16:18:16
相关问题
动态布局下加载loading效果实现
253浏览 • 1回复 待解决
「多态控件」效果样式确认
479浏览 • 1回复 待解决
如何实现列表页单选效果
896浏览 • 0回复 待解决
canvas如何实现水印效果
374浏览 • 1回复 待解决
滑动组件如何实现单边spring效果
501浏览 • 1回复 待解决
如何实现图片大图预览效果
495浏览 • 1回复 待解决
如何实现类似keyframes效果
658浏览 • 1回复 待解决
如何实现组件阴影效果
341浏览 • 1回复 待解决
图片模糊效果如何实现
317浏览 • 1回复 待解决
如何等效实现JSONObejct效果
220浏览 • 1回复 待解决
如何实现一个自定义样式toast提示
590浏览 • 1回复 待解决
如何实现通用吸顶效果
152浏览 • 1回复 待解决
如何实现动画转场效果
367浏览 • 1回复 待解决
如何实现视频滤镜效果
627浏览 • 1回复 待解决
如何实现分组列表吸顶/吸底效果
781浏览 • 1回复 待解决
组合样式怎样去实现导入导出
582浏览 • 1回复 待解决
如何实现全局浮窗效果
586浏览 • 1回复 待解决
文字动画效果如何实现
637浏览 • 0回复 待解决
半模态转场来实现弹框样式页面
366浏览 • 1回复 待解决
@Extend样式如何跨组件共享?
1123浏览 • 1回复 待解决