[LVGL9] how to get size of scale widget?

Description

I have tried to create a scale widget on LVGL9 by
lv_example_scale_1() as the following code.

image

However when I want to know the size of the scale,
it shows the width = 0 and the height = 0.

How to receive the correct width and height of the scale?
Thank you.

What MCU/Processor/Board and compiler are you using?

MCU = ESP32

What LVGL version are you using?

LVGL 9

What do you want to achieve?

Get the scale widget’s width and the height .

Hi,

See here:

LVGL doesn’t recalculate all the coordinate changes immediately. This is done to improve performance. Instead, the objects are marked as “dirty” and before redrawing the screen LVGL checks if there are any “dirty” objects. If so it refreshes their position, size and layout.

In other words, if you need to get the coordinate of an object and the coordinates were just changed, LVGL needs to be forced to recalculate the coordinates. To do this call lv_obj_update_layout().

2 Likes

Thank you very much.