01-17-2013 07:09 AM
Is there a way to center vertically the text on a Label?
Suppose you have a label with heithg=200 and I want to center it vertically.
Is it possible?
Solved! Go to Solution.
01-17-2013 08:59 AM - edited 01-17-2013 09:00 AM
I think there is no such thing as valign or so, but if you set the label's height to the actual height of the text you can then center it vertically by applying equal top and bottom margin (if you're using layoutData) or something like
myLabel.y = (availableHeight - myLabel.height) / 2 ...
Note that you can't get the text height until the label is rendered or at least placed in the display list (otherwise it returns 0)
myLabel.validateNow(); myLabel.height = myLabel.textHeight;
My app : Get set - Get up! Get ready for the snooze revolution.
01-17-2013 12:40 PM