Bar (lv_bar)

The Bar Widget has a background and an indicator. The length of the indicator against the background indicates the Bar's current value.

Edit on GitHub

Overview

The Bar Widget has a background and an indicator. The length of the indicator against the background indicates the Bar's current value.

Both the start and end values of the Bar can be set. Changing the start value to a value other than the minimum value in its range adjusts the start position of the indicator.

Parts and Styles

Usage

Orientation and size

Value and range

A new value can be set with 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, and the default drawing direction is from left to right in horizontal mode and bottom to top in vertical mode. If the minimum value is greater than the maximum value, like 100..0, the drawing direction is reversed.

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:

Data binding

To get familiar with observers, subjects, and data bindings in general visit the Observer page.

This method of subscribing to an integer Subject affects a Bar Widget's integer value directly. Note that this is a one-way binding (Subject ==> Widget) so when the subject changes the Bar will be updated too.

It supports integer and float subjects.

Events

No special events are sent by Bar Widgets.

Further Reading

Learn more about Events emitted by all Widgets.

Learn more about events.

Keys

No Keys are processed by Bar Widgets.

Further Reading

Learn more about Keys.

Examples

Simple Bar

Styling a bar

Temperature meter

Stripe pattern and range value

Bar with LTR and RTL base direction

Custom drawer to show the current value

Bar with opposite direction

API

How is this guide?

Last updated on

On this page