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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 38
Registered: ‎12-27-2010
My Device: BlackBerry Z10/Q10 - BlackBerry PlayBook
My Carrier: Vodafone NL

label.textHeight returns 0

Hello there!

I am trying to vertically center a Label. So what I did was: 

title.setPosition(185, 150 / 2 - (title.textHeight / 2));

			

 But it didnt work, so I traced out title.textHeight , and strange enough it returns '0'. 

 

This is my entire code:

 

title	=	new Label();
			title.height	=	20;
			title.setPosition(185, 150 / 2 - (title.textHeight / 2));
			title.autoSize	=	TextFieldAutoSize.LEFT;
			title.format	=	textFormat;
			

 

I've also tried it without setting a textformat. 

 

 

Thanks!

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: label.textHeight returns 0

Which Label class? There are many to choose from. What is the line of the import statement?

You are setting the height, why not use that instead?
New Developer
Posts: 38
Registered: ‎12-27-2010
My Device: BlackBerry Z10/Q10 - BlackBerry PlayBook
My Carrier: Vodafone NL

Re: label.textHeight returns 0

I'm using the following import 

import qnx.fuse.ui.text.Label;

 And I accidently copied the test which I tried, it doenst either work when I set the height. 

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: label.textHeight returns 0

Under the BB10 libraries, I am getting a textHeight for the label. Is this under the PlayBook library or the BB10 library? when are you calling this? During construction or during a refresh (draw/updateDisplayList)? Try delaying the call with either during a frame update/refresh or by using setTimeout.
Developer
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)
My Carrier: Regional

Re: label.textHeight returns 0

Set the text before you get the textHeight, else if there's no text, the textHeight will return 0.