Description
grid_column_align
seems to have no effect.
What MCU/Processor/Board and compiler are you using?
ESP32 ESP-IDF and others
What LVGL version are you using?
8.4 - also tested on the master branch from Github, same result.
What do you want to achieve?
Apply layout styles to grid tracks without having to style each cell individually
What have you tried so far?
All variations of grid_column_align
- no matter what value I set the columns are always left-aligned.
Code to reproduce
static const lv_coord_t page_1_row_dsc[] = {LV_GRID_FR(1),LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
static const lv_coord_t page_1_column_dsc[] = {LV_GRID_FR(1),LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
lv_style_t *bdr_style;
lv_obj_t *page_1;
lv_obj_t *cell_0_0;
lv_obj_t *cell_0_1;
lv_obj_t *cell_1_0;
lv_obj_t *cell_1_1;
void setup_page() {
bdr_style = malloc(sizeof(lv_style_t));
lv_style_init(bdr_style);
lv_style_set_align(bdr_style, LV_ALIGN_CENTER);
lv_style_set_border_color(bdr_style, lv_color_hex(0x808080));
lv_style_set_border_width(bdr_style, 2);
lv_style_set_pad_all(bdr_style, 4);
page_1 = lv_obj_create(lv_scr_act());
lv_obj_set_layout(page_1, LV_LAYOUT_GRID );
lv_obj_set_style_grid_row_dsc_array(page_1, page_1_row_dsc, 0);
lv_obj_set_style_grid_column_dsc_array(page_1, page_1_column_dsc, 0);
lv_obj_set_style_grid_column_align(page_1, LV_GRID_ALIGN_CENTER, 0);
lv_obj_set_style_border_color(page_1, lv_color_hex(0xFF0000), (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_border_width(page_1, 2, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_pad_all(page_1, 10, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_width(page_1, lv_pct(100), (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
cell_0_0 = lv_label_create(page_1);
lv_obj_add_style(cell_0_0, bdr_style, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_pos(cell_0_0, 0, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_pos(cell_0_0, 0, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_span(cell_0_0, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_span(cell_0_0, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_label_set_text(cell_0_0, "Cell 0/0" );
cell_0_1 = lv_label_create(page_1);
lv_obj_add_style(cell_0_1, bdr_style, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_pos(cell_0_1, 0, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_pos(cell_0_1, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_span(cell_0_1, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_span(cell_0_1, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_label_set_text(cell_0_1, "Cell 0/1" );
cell_1_0 = lv_label_create(page_1);
lv_obj_add_style(cell_1_0, bdr_style, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_pos(cell_1_0, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_pos(cell_1_0, 0, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_span(cell_1_0, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_span(cell_1_0, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_label_set_text(cell_1_0, "Cell 1/0" );
cell_1_1 = lv_label_create(page_1);
lv_obj_add_style(cell_1_1, bdr_style, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_pos(cell_1_1, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_pos(cell_1_1, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_row_span(cell_1_1, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_obj_set_style_grid_cell_column_span(cell_1_1, 1, (int)LV_STATE_DEFAULT|(int)LV_PART_MAIN);
lv_label_set_text(cell_1_1, "Cell 1/1" );
}