Text align top left in Table Widget


If I have 2 columns in a table component, then I want both columns to have the text aligned TOP_LEFT. How can I achieve that with the table widget in LVGL 8.2 ? I tried several approaches, but couldn’t make the left column’s text align top left, when the right columns text is very long.

How can I force the widget to align text in the top left ? Many thanks !

What MCU/Processor/Board and compiler are you using?

Linux Framebuffer

What LVGL version are you using?

LVGL 8.2

What do you want to achieve?

I want to align text in all columns ALWAYS in the top_left of the cell. No auto alignment, please.

What have you tried so far?

For instance

    lv_obj_set_style_text_align(my_table, LV_ALIGN_TOP_LEFT, LV_PART_MAIN);
    lv_obj_set_style_align(my_table, LV_ALIGN_TOP_LEFT, LV_PART_ITEMS);

also with the draw callback :

Code to reproduce

  static void draw_part_event_cb(lv_event_t * e)
        lv_obj_t * obj = lv_event_get_target(e);
        lv_obj_draw_part_dsc_t * dsc = (lv_obj_draw_part_dsc_t *) lv_event_get_param(e);
        /*If the cells are drawn...*/
        if(dsc->part == LV_PART_ITEMS) {
            uint32_t row = dsc->id /  lv_table_get_col_cnt(obj);
            uint32_t col = dsc->id - row * lv_table_get_col_cnt(obj);

            /*In the first column align the texts to the right*/
            if(col == 0) {
                dsc->label_dsc->align = LV_TEXT_ALIGN_LEFT;
//text align top left is missing probably
            if(col == 1) {
                dsc->label_dsc->font = &my_font;
                dsc->label_dsc->align = LV_TEXT_ALIGN_LEFT;
                dsc->label_dsc->ofs_x = 0;
                dsc->label_dsc->ofs_y = 0;

Thanks for reading :slight_smile: