How to make a label wrap and scroll vertically? And possible recoloring bug


I have a screen in which I need to display an arbitrarily long label. I want to have the label centered, with wrapping enabled and scrolling vertically if the text does not fit.

As you can see I have the centering and wrapping working just fine, but I don’t see how to enable scrolling.

Another issue I have is that there seems to be a bug with recoloring when the label wraps. It’s not very noticeable in the picture, but the artist section of the label should be slightly darker than the song section. In the picture the “long artist name” text shows uncolored.

This is how I’m setting it up:

lv_label_set_text_fmt(m_label, "%s #808080 - %s#",

Is this expected or is this a bug? I’m currently on v8.1.

Thanks for your help!

For the scrolling you can do this:

  lv_obj_t * label = lv_label_create(lv_scr_act());
  lv_obj_set_style_bg_opa(label, LV_OPA_COVER, 0);
  lv_obj_set_style_bg_color(label, lv_color_hex(0xff8888), 0);
  lv_obj_set_size(label, 100, 100);
  lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL);


Note that, if the text’s width is larger than the widget’s width it will scroll horizontally. That is there is no wrapping with scrolling.

If you need more control you can easily implement vertical scrolling yourself too:

  1. Please the label on a transparent lv_obj and set width = lv_pct(100) for the label.
  2. Create an animation which changes the y position of the label.

Yes, it’s a known bug. :frowning:
I suggest taking a look at lv_span which is more future rich implementation to changing the style of text snippets.

1 Like

Is there a known way to fix it? I can put a PR together to fix the bug if I get some guidance.

Would it be a good idea to implement a new LV_LABEL_LONG_WRAP_SCROLL_VERTICALLY long mode? I can also try to get that working if such a feature is wanted.

I see no problem with having an option like this. Please send a PR or open an issue to discuss it if needed.