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

Native Development

Reply
Developer
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar

define the maximum length of a label

Hi I have several strings from a Json online that I use on my main qml, so sometimes the length it's too much, is there a way to give a maximum length for that label and that the text size fits according to it?
Developer
Posts: 543
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: define the maximum length of a label

[ Edited ]

You can define maximum line count with autoSize

Label{
multiline: true
autoSize{
maximumLineCount: 4
}
}


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: define the maximum length of a label

[ Edited ]

@Benecore I believe they were asking for limiting the text not the lines.

 

The best you can do at the moment is limit the string length at the time it is read and accept the fade-out (if all W's Smiley Happy) or use the textFit function (10.2 only)...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__label.html#function-textfit

 

Before 10.2 you could use a fixed width font and do the calculation yourself to fit the text in to the width of the label.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.