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