Can I auto-fit a table column width to text?


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

SDL simulator. GCC.

What LVGL version are you using?


What do you want to achieve?

When creating a table and filling it with data, it’s possible to set it to crop text ie. not wrap it. Is it possible to either

  • get the table to automatically fit each column to the unwrapped text? or
  • get the resulting text widths so I can compute and set the maximum column width myself?

What have you tried so far?

Not much, the API doesn’t expose anything that seems like I could use it for this. I’ve looked through the source, but it didn’t inspire a solution.

Unfortunatly it’s not supported. You need to manually set the width of the columns.

Thanks for confirming that. The potential values for the labels are known in advance, so I can adjust it by eye. If I ever need something more complex I can roll my own control that uses proper labels.