The docs say that labels size is always expanding with long text, except when the size is explicitly set by a layout.
However, this code does not allow me to scroll text:
void lv_example_grid_1(void) {
static lv_coord_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST};
static lv_coord_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST};
/*Create a container with grid*/
lv_obj_t *cont = lv_obj_create(lv_scr_act());
lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0);
lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0);
lv_obj_set_size(cont, 300, 220);
lv_obj_center(cont);
lv_obj_set_layout(cont, LV_LAYOUT_GRID);
lv_obj_t *label;
uint32_t i;
for (i = 0; i < 9; i++) {
uint8_t col = i % 3;
uint8_t row = i / 3;
label = lv_label_create(cont);
lv_obj_set_grid_cell(label, LV_GRID_ALIGN_CENTER, col, 1,
LV_GRID_ALIGN_CENTER, row, 1);
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
lv_label_set_text_fmt(label, "c%d, r RRRR%d RRR RRRRR RRRRR", col, row);
lv_obj_center(label);
}
}
I understand that changing the LV_GRID_ALIGN_CENTER
to LV_GRID_ALIGN_STRETCH
will make the text scroll, but I don’t understand why. Is there a workaround for this?