Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Phone API Reference - UI Classes (Widgets) - Text - fitLabel

fitLabel

Description

Resizes the box around the widget to fit it to the contents. A padding argument is optional, to add additional pixels on each side of the text.

Basic Example: 

Code Block
 textObj.fitLabel([padding]);

Note: if a text widget is aligned with Widget.WRAP, fitLabel() will not alter its width.

...

fitLabel for a text widget with a 2 pixel padding

Code Block
var foo = new Text(0, 0, 100, Text.LINE_HEIGHT, 'Test Text');
foo.setProp('boxType', Widget.FLAT_BOX)
   .setProp('labelColor', 'white')
   .setProp('color', 'black')
   .fitLabel(2);