Lvgl8.2 Text display position

Create a label, how to centre the text like this,For example, an effect like this:
image

See Positions, sizes, and layouts — LVGL documentation

I used LV_TEXT_ALIGN_CENTER, but it didn’t work the way I wanted, sorry, I didn’t find it in the documentation…

LV_TEXT_ALIGN_CENTER is like left/right/center alignment in text editors; just aligns the lines horizontally.

lv_obj_center(label) places the widget to the center of its parent.

I want the string in the label to be in the most central position, not to set the position of the label.


p1: Use LV_TEXT_ALIGN_CENTER for string positions in tags
p2: I want the effect string in the centre of the label

So the whole orange rectangle is a label.

There is no way to vertically align the label this way.

You can set e.g. lv_obj_set_style_pad_top(label, 50), but it’s a little bit cumbersome.

1 Like

Thanks for the reply, I’ll try to fix it