回复
     零基础学鸿蒙编程-UI控件_ProgressBar 原创
蓝不蓝编程
 发布于 2021-11-2 22:40
 浏览
 0收藏
什么是ProgressBar
ProgressBar是用于展示进度的UI控件,.
1.横向进度
效果图

代码
  <ProgressBar
        ohos:height="match_content"
        ohos:width="match_parent"
        ohos:max="100"
        ohos:min="0"
        ohos:progress="70"/>
2.纵向进度
效果图

代码
<ProgressBar
        ohos:height="90vp"
        ohos:width="match_content"
        ohos:max="100"
        ohos:min="0"
        ohos:orientation="vertical"
        ohos:progress="70"
        ohos:progress_element="#FF8800"/>
3.横向分段展示进度
效果图

代码
<ProgressBar
        ohos:height="20vp"
        ohos:width="match_parent"
        ohos:divider_lines_enabled="true"
        ohos:divider_lines_number="5"
        ohos:max="100"
        ohos:min="0"
        ohos:progress="80"
        ohos:progress_element="#FF8800"
        ohos:progress_width="5vp"/>
4.横向进度条展示+文字
效果图

代码
    <ProgressBar
        ohos:height="20vp"
        ohos:width="match_parent"
        ohos:max="100"
        ohos:min="0"
        ohos:progress="30"
        ohos:progress_element="#FF8800"
        ohos:progress_hint_text="30%"
        ohos:progress_hint_text_color="#000000"
        ohos:progress_width="5vp"/>
基础样例完整源代码
https://gitee.com/hspbc/harmonyos_demos/tree/master/progressBarDemo
常用属性说明
| 属性名 | 用途 | 
|---|---|
| ohos:width | 设置控件宽度,可设置为:match_parent(和父控件一样),match_content(按照内容自动伸缩),设置固定值(如200vp) | 
| ohos:height | 设置控件高度,可设置为:match_parent(和父控件一样),match_content(按照内容自动伸缩),设置固定值(如200vp) | 
| ohos:layout_alignment | 在父控件内对齐方式,可选值:left:居左;start:居左;center:居中;right:居右;end:居右 | 
| ohos:background_element | 设置背景,可以是色值(如#FF0000)或图片等 | 
| ohos:visibility | 可选值: visible(显示), invisible(隐藏,但是仍占据UI空间),hide(隐藏,且不占UI空间) | 
| ohos:progress | 设置当前进度 | 
| ohos:max | 设置最大进度值 | 
| ohos:min | 设置最小进度值 | 
| ohos:orientation | 设置展示方向,默认横向,可选值:vertical:纵向;horizontal:横向 | 
| ohos:progress_element | 设置进度条颜色,样例:ohos:progress_element=“#FF8800” | 
| ohos:divider_lines_enabled | 设置是否显示分段,可选值:true:显示分段;false:不显示 | 
| ohos:divider_lines_number | 设置分段数量 | 
| ohos:progress_width | 设置进度条的宽度,样例:ohos:progress_width=“5vp” | 
| ohos:progress_hint_text | 设置进度条上文字,样例:ohos:progress_hint_text=“30%” | 
| ohos:progress_hint_text_color | 设置进度条上文字颜色,样例:ohos:progress_hint_text_color=“#000000” | 
| 更多属性及实际效果,可以在开发工具里自行体验. | 
©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
  标签 
  已于2021-11-26 13:55:35修改
 
        赞
        
 
        收藏 
      
 回复
  相关推荐
 



















