Hello!
Trying to get some elements centered horizontally in a ListWidget
. I’ve got a main stack that’s on layoutVertically()
, and a few stacks added to that, each is on layoutHorizontally()
. Others seem to have solved this by adding addSpacer()
to either side of the horizontal elements, but those end up collapsing the content between into ellipses:
Any ideas? Thanks!
Relevant code, for the “3.5 U @ 7:21…” line:
// Main stack
let mainStack = listWidget.addStack();
mainStack.layoutVertically();
// BG stack
// Code for first horizontal stack removed for clarity; is short, so centers fine.
// Dose stack
let doseStack = mainStack.addStack();
doseStack.layoutHorizontally();
doseStack.centerAlignContent();
doseStack.addSpacer();
const doseInfo = doseStack.addText(ns_data.doseText + ' @ ' + ns_data.doseTimeText);
doseInfo.textColor = new Color('ffffff');
doseInfo.font = Font.semiboldSystemFont(14);
doseStack.addSpacer();