Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Highlighted
Developer
Posts: 223
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone
Accepted Solution

(bb10) center text vertically on label

Hi guys!

 

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?

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
Developer
Posts: 194
Registered: ‎11-12-2010
My Device: Not Specified

Re: (bb10) center text vertically on label

[ Edited ]

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.

Developer
Posts: 223
Registered: ‎04-26-2012
My Device: Z10
My Carrier: Vodafone

Re: (bb10) center text vertically on label

Perfect! good idea, hadn't about it!

 

Thanks man

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords