Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

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: 

 textObj.fitLabel([padding]);

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

Parameters

Name

Required

Type

Default

Description

padding

No

integer

0

Number of pixels to add to the text box on each side of the text.

Examples

fitLabel for a text widget with a 2 pixel padding

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);

  • No labels