Lv_label_set_long_mode() doesn't work

When using the list component, if the text is too long, set LV_ LABEL_ LONG_ SCROLL_ CIRCULAR has no effect.(lvgl 8.2.0)

Please send a code snippet to reproduce the issue.

Iā€™m late. The code is as follows:

obj_btn = lv_list_add_btn(obj_list, ResourcePool::GetImage("wifi_on"), (char *)ssid_buf);

Does not scroll when ssid_buf is too long.

lv_obj_t * lv_list_add_btn(lv_obj_t * list, const void * icon, const char * txt)

{

    LV_LOG_INFO("begin");

    lv_obj_t * obj = lv_obj_class_create_obj(&lv_list_btn_class, list);

    lv_obj_class_init_obj(obj);

    lv_obj_set_size(obj, LV_PCT(100), 100);

    //lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW);



    if(icon) {

        lv_obj_t * img = lv_img_create(obj);

        lv_img_set_src(img, icon);

        lv_obj_align(img,LV_ALIGN_RIGHT_MID,-30,0);

    }



    if(txt) {

        lv_obj_t * label = lv_label_create(obj);

        lv_label_set_text(label, txt);

        lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);

        lv_obj_set_style_text_color(label, lv_color_hex(0xFFFFFF), 0);

        lv_obj_align(label,LV_ALIGN_LEFT_MID,10,0);

        //lv_obj_set_flex_grow(label, 1);

    }



    return obj;

}

Do you use a custom style?

With the default theme with this code it works for me:

 btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Something long to demonstrate scroll");

Yes, thank you for your reply! I customized lv_ list_ add_ Btn ().

and then I try to switch back to the default to scroll.

It should be that I have not set the width of the label component.

Yes, the label should have a fixed width (i.e. not LV_SIZE_CONTENT which the default) to make the scroll animation work. Else LVGL will extend the size of the label to the size of text and there will be no reason to scroll as the whole text fits into the widget.

1 Like

Thanks again for your reply, which has benefited me a lot.