Bar (lv_bar)
Bar (lv_bar)
Overview
The bar object has a background and an indicator on it. The width of the indicator is set according to the current value of the bar.
Vertical bars can be created if the width of the object is smaller than its height.
Not only the end, but also the start value of the bar can be set, which changes the start position of the indicator.
Parts and Styles
LV_PART_MAIN
The background of the bar and it uses the typical background style properties. Adding padding makes the indicator smaller or larger. Theanim_time
style property sets the animation time if the values set withLV_ANIM_ON
.LV_PART_INDICATOR
The indicator itself; also uses all the typical background properties.
Usage
Value and range
A new value can be set by lv_bar_set_value(bar, new_value, LV_ANIM_ON/OFF)
. The value is interpreted in a range (minimum and maximum values) which can be modified with lv_bar_set_range(bar, min, max)
. The default range is 0..100.
The new value in lv_bar_set_value
can be set with or without an animation depending on the last parameter (LV_ANIM_ON/OFF
).
Modes
The bar can be one of the following modes:
LV_BAR_MODE_NORMAL
A normal bar as described aboveLV_BAR_SYMMETRICAL
Draw the indicator from the zero value to current value. Requires a negative minimum range and positive maximum range.LV_BAR_RANGE
Allows setting the start value too bylv_bar_set_start_value(bar, new_value, LV_ANIM_ON/OFF)
. The start value always has to be smaller than the end value.
Events
LV_EVENT_DRAW_PART_BEGIN
andLV_EVENT_DRAW_PART_END
are sent for the following parts:LV_BAR_DRAW_PART_INDICATOR
The indicator of the barpart
:LV_PART_INDICATOR
draw_area
: area of the indicatorrect_dsc
See the events of the Base object too.
Learn more about Events.
Keys
No Keys are processed by the object type.
Learn more about Keys.
Example
API
警告
doxygenfile: Unable to find project ‘lvgl’ in breathe_projects dictionary
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具