Hi!
I am writing my very first Connet IQ widget and I have a question about CustomMenuItem alignment.
My CustomMenu is very simple: title at the top and a list of CustomMenuItem made of icon plus a label.
I would like the CustomMenuItem items to be right aligned and a bit nudged towards the center, so that we get a nice looking list which still allows shorter and longer labels to fit neatly. The problem is that I haven't figure out how to do this beside hard coding values / percentages which (you guessed it) might work on one device but not on others.
I am sure this is a common issue, is there a best practice to get around this? Thanks!
If relevant, I am targeting 3.0.0+ devices.
public function draw(dc as Graphics.Dc) as Void {
var baseX = dc.getWidth() / 4;
var spacing = 6;
var bitmapX = baseX;
var bitmapY = (dc.getHeight() - _bitmap.getHeight()) / 2;
dc.drawBitmap(bitmapX, bitmapY, _bitmap);
var labelHeight = dc.getFontHeight(Theme.P_FONT);
var labelX = baseX + _bitmap.getWidth() + spacing;
var labelY = (dc.getHeight() - labelHeight) / 2;
dc.drawText(labelX, labelY, Theme.P_FONT, _label, Graphics.TEXT_JUSTIFY_LEFT);
}