#鸿蒙通关秘籍#如何在中间区域自定义半圆环进度条的样式?

HarmonyOS
2024-11-29 14:23:18
591浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
雪地足迹JSON

通过传入自定义内容,可以改变进度条中间显示的内容。以下为配置不同中间样式的代码示例:

CircularProgressBar({ radius: 100, currentValue: this.value, activeColor: '#2EB977' }) {
  Column() {
    Text('剩余里程(km)').fontSize(12).fontColor('#FFF')
    Text((100 - this.value).toString())
      .fontSize(45)
      .fontColor('#FFF')
      .fontWeight(700)
      .margin({ top: 8 })
  }.margin({ top: '18%' })
}

CircularProgressBar({
  radius: 120,
  currentValue: this.value,
  activeColor: '#FAA10F',
  showPercentage: false
}) {
  Column() {
    Flex({ alignItems: ItemAlign.Baseline, justifyContent: FlexAlign.Center }) {
      Text(getPercentageTxt()).fontColor('#fff').fontSize(55)
      Text('%').fontSize(15).fontColor('#fff').margin({ left: 2 })
    }

    Text(`已行驶${this.value}km`).fontSize(12).fontColor('#fff').margin({ top: 8 })
  }.margin({ top: '15%' })
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
分享
微博
QQ
微信
回复
2024-11-29 16:36:42


相关问题
HarmonyOS 进度条样式
756浏览 • 1回复 待解决
如何自定义滚动样式
1120浏览 • 1回复 待解决