How to Sort Characters

Thank you for providing a good library.


box = lv_obj_create(main_page, NULL);
lv_obj_set_size(box, 200, 45);
lv_obj_set_style(box, &lv_style_plain);
lv_obj_set_pos(box, 102,11);

Label = lv_label_create(main_page, NULL);
lv_obj_set_style(Label, &Label_Kor_White);
lv_obj_align(Label, box, LV_ALIGN_CENTER, 0, 0);
lv_label_set_text(Label, “소금”);

If you use it like above, center alignment is done well. If you use it like above, center alignment is done well. However, when a character goes beyond two letters, there is a phenomenon that the center line is not aligned and it is tilted to one side. How do I fix it?

Is there a way to sort to the right of the letter? For example, I want to adjust the position of increasing numbers.
I am sorry that English is poor.

Hi,

Which part do mean exactly? Please mark it with an arrow or circle?

Do you mean the baselines are not aligned?

You should just set the text first and align after that:

lv_label_set_text(...);
lv_obj_align(...);

Thanks to that, it worked out well. Thank you.

Glad to hear it worked!

This happens because the centering is done based on the current width of the label. So if you had a label centered

-----------My text-----------

and then you made the text longer

-----------Much longer text--

the label won’t automatically re-center itself when it’s width changes.

1 Like