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

Java 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
Developer
Posts: 108
Registered: ‎08-05-2008
My Device: Not Specified
Accepted Solution

Centering text in the LabelField

I want to center the text in a label.  The label takes up all the width of the screen, but the text inside it won't center.

 

LabelField lbl = new LabelField("center this", LabelField.USE_ALL_WIDTH | LabelField.FIELD_HCENTER);

 

Am I missing something massively simple?

Thanks.

BlackBerry Development Advisor
Posts: 15,888
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Centering text in the LabelField

Please ensure that the manager the field has been added to is also using the USE_ALL_WIDTH style.  Otherwise it could be restricting the field's width.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Highlighted
Developer
Posts: 108
Registered: ‎08-05-2008
My Device: Not Specified

Re: Centering text in the LabelField

I am just adding it to the form itself (e.g. which inherits from MainScreen).  I assume that's using USE_ALL_WIDTH since all other elements on the screen take up full width.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Centering text in the LabelField

Try this:

LabelField lbl = new LabelField("center this", LabelField.USE_ALL_WIDTH | DrawStyle.HCENTER);

Developer
Developer
Posts: 167
Registered: ‎11-12-2008
My Device: Not Specified

Re: Centering text in the LabelField

Note that if you don't use USE_ALL_WIDTH the label could be cut off.  Just spent hours trying to figure out why the label was being cropped and that was the reason!