Best practices with multiple display dimensions?



I’m working on an application that may run on a different number of screen dimensions. I’d like to make it easy to build and optionally configurable at runtime to avoid rebuilding with screen dimensions constants so that the application binary is the same on the devices we run on.

For now, my question is about designing dimensions of some aspects of the screens. For now, unless I’m mistaken the usual way to do is to go through fixed size dimensions so that alignment and positions are easier to setup.

Since I’d like to create a runtime dimensional screen (including font size) I have to create layouts depending on widget sizes. For example one of my view contains a form like this:

But since the labels on the left are not known in size in advance I must either:

  • Use a fixed size depending on the font selected at runtime.
  • Recalculate by calling lv_obj_update_layout on the parent widget so that I can readjust parent size depending on all children widgets and adjust their positions.

What are your advises on that? I would like to save space especially in height so the idea is that the form should take as minimum as possible and just use the padding between each form “element”.

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

Mostly waveshare screens and SDL on desktop.

What LVGL version are you using?