Lable :LV_LABEL_LONG_BREAK

Line breaks are not as expected, why is this ?

my code:

lv_obj_t *obj = lv_obj_create(lv_scr_act(),NULL);

lv_obj_set_size(obj,200,200);

lv_obj_t *label1 = lv_label_create(obj,NULL);

lv_label_set_long_mode(label1,LV_LABEL_LONG_BREAK);

lv_obj_set_size(label1,100,0);  

lv_obj_t * label2 = lv_label_create(obj,NULL);  

lv_label_set_long_mode(label2,LV_LABEL_LONG_BREAK);

lv_obj_set_size(label2,100,0);  

lv_obj_set_pos(label2,0,50);

lv_label_set_text(label1,"123456AAAAAB");  

lv_label_set_text(label2,"123456 AAAAA");

What can I do to display the effect below

b

Hi @lun,

I think you are using V7 of LVGL based on your example.

If you look in ‘lv_conf.h’ and locate this entry:

 /*Can break (wrap) texts on these chars*/
#define LV_TXT_BREAK_CHARS                  " ,.;:-_"

If you don’t want the text to be broken at a ‘space character’ when it does not fit the width of the label, you can remove the space from the string defined here so it becomes:

#define LV_TXT_BREAK_CHARS                  ",.;:-_"

This entry defines all the characters the ‘break algorithm’ is allowed to create a text break at.

I hope that makes sense and is a help.

Kind Regards,

Pete

Thank you very much!

1 Like