Center text issue

I have this code:

addStretch(
  twoImg,
  twoNameDisplay,
  twoLink,
  row)
row.addSpacer(10)

I want to centre the text (twoNameDisplay) but everything I tried fails…
Grateful for someone pointing out something I missed.
Thanks

What does the addStretch function do? As far as I know it’s not built-in. My guess would be to add row.addSpacer() before and after to centre whatever items are added with addStretch.

Here is my addStretch function (text align included but does not work!):

function addStretch(img, name, link, r) {
  let stack = r.addStack()
  stack.layoutVertically()
  stack.url = link
  
  let wimg = stack.addImage(img)
  wimg.cornerRadius = 4
  stack.addSpacer(4)
  
  let wname = stack.addText(name)
  wname.font = Font.semiboldRoundedSystemFont(14)
  wname.textColor = Color.white()
  stack.centerAlignContent()
  stack.addSpacer(4)
}

thanks

I solved it with an additional stack for the text

Good job. Like I said, try addSpacer() without arguments to expand to fill the space.