Forum Discussion
joetesta
9 years agoRoku Guru
"jedashford" wrote:
Thank you. I'll give this a try. I'm worried a solution like this wont scale well with different screen resolutions. We'll find out...
I think I got this to work by having a Label that's a child element of the button, (and the same width) and the label text can be centered with;
<Label id="itemLabel" horizAlign="center" />
WSJTim
6 years agoBinge Watcher
If anyone else stumbles on this, this solution would've required a lot more work for me, dealing with changing the color of the Label when the button gains and loses focus. While hokey, this little utility function fixed the problem for me:
sub centerButtonLabel(button as object)
for i = 0 to button.getChildCount() - 1
child = button.getChild(i)
if child.subtype() = "Label"
child.horizAlign = "center"
end if
end for
end subI just call this in the onVisible for my screen. Works like a charm. Should Roku just support this as a property on the stock Button? Yes.