I have seen this a lot where the data and the units are different sized fonts and I like the way it looks. It works good for time as well where the AM / PM are small
Nothing that is probably how it will need to be done. But how can I get one label to appear right after another one. The with of the text will differ depending on its value so the “units” label will need to keep moving left or right whenever the “Data” label is updated.
I’m sure this is possible I just don’t know how to get the label to move.
I would suggest you don’t want the label to move. Give the labels a fixed width (perhaps 50% each, depending on what they’re contained in) and right align the text in the value, left align the units. Add padding (probably to both) to provide some space between them.
That’s not what I’m trying to do. Take a look at the image at the top of the post. The data + units is perfectly centered under each graphic element. if its 1 kwh or 1000 kwh it move the data + units around to make it look good.
There are obviously easier ways to do this such as just making the data + units the same font. But it doesn’t look as nice. This is all about ascetics.
The old graphics system has a simple command (GetTextWidth) to do this. Is there no command or helper in LVGL that can calculate the width in pixels of the text?
Great. Technically to get the baselines to align it’s pad_bottom you should use. The different font sizes obviously have baselines that are a different height so you need to pad the label with smaller font up a bit from the bottom.