Titanium.UI.Label

Object of Titanium.UI.
Platform Since
Android 0.8
iPhone 0.8
iPad 0.8
Mobile Web 1.8

Summary

A text label, with optional background image.

Description

Use the Titanium.UI.createLabel method to create a label.

Code Examples

Basic Label

Create a label with a nice text shadow, 48px font that's aligned center and height auto.

var l2 = Titanium.UI.createLabel({
    text:'Appcelerator',
    height:'auto',
    width:'auto',
    shadowColor:'#aaa',
    shadowOffset:{x:5,y:5},
    color:'#900',
    font:{fontSize:48},
    textAlign:'center'
});

Methods

Name Summary
add

Adds a child to this view's hierarchy.

addEventListener

Adds the specified callback as an event listener for the named event.

animate

Animates this view.

convertPointToView

Translates a point from this view's coordinate system to another view's coordinate system. (Android, iPhone, iPad only.)

fireEvent

Fires a synthesized event to any registered listeners.

getAnchorPoint

Gets the value of the anchorPoint property. (iPhone, iPad only.)

getAnimatedCenterPoint

Gets the value of the animatedCenterPoint property. (Android, iPhone, iPad only.)

getAutoLink

Gets the value of the autoLink property. (Android only.)

getBackgroundColor

Gets the value of the backgroundColor property.

getBackgroundDisabledColor

Gets the value of the backgroundDisabledColor property. (Android only.)

getBackgroundDisabledImage

Gets the value of the backgroundDisabledImage property. (Android only.)

getBackgroundFocusedColor

Gets the value of the backgroundFocusedColor property. (Android only.)

getBackgroundFocusedImage

Gets the value of the backgroundFocusedImage property. (Android only.)

getBackgroundGradient

Gets the value of the backgroundGradient property. (iPhone, iPad, Mobile Web only.)

getBackgroundImage

Gets the value of the backgroundImage property.

getBackgroundLeftCap

Gets the value of the backgroundLeftCap property. (iPhone, iPad only.)

getBackgroundPaddingBottom

Gets the value of the backgroundPaddingBottom property. (iPhone, iPad only.)

getBackgroundPaddingLeft

Gets the value of the backgroundPaddingLeft property. (iPhone, iPad only.)

getBackgroundPaddingRight

Gets the value of the backgroundPaddingRight property. (iPhone, iPad only.)

getBackgroundPaddingTop

Gets the value of the backgroundPaddingTop property. (iPhone, iPad only.)

getBackgroundSelectedColor

Gets the value of the backgroundSelectedColor property. (Android, Mobile Web only.)

getBackgroundSelectedImage

Gets the value of the backgroundSelectedImage property. (Android, Mobile Web only.)

getBackgroundTopCap

Gets the value of the backgroundTopCap property. (iPhone, iPad only.)

getBorderColor

Gets the value of the borderColor property.

getBorderRadius

Gets the value of the borderRadius property.

getBorderWidth

Gets the value of the borderWidth property.

getBottom

Gets the value of the bottom property.

getCenter

Gets the value of the center property.

getColor

Gets the value of the color property.

getEllipsize

Gets the value of the ellipsize property. (Android only.)

getFocusable

Gets the value of the focusable property. (Android only.)

getFont

Gets the value of the font property.

getHeight

Gets the value of the height property.

getHighlightedColor

Gets the value of the highlightedColor property. (iPhone, iPad only.)

getHtml

Gets the value of the html property. (Android, Mobile Web only.)

getKeepScreenOn

Gets the value of the keepScreenOn property. (Android only.)

getLayout

Gets the value of the layout property.

getLeft

Gets the value of the left property.

getMinimumFontSize

Gets the value of the minimumFontSize property. (iPhone, iPad only.)

getOpacity

Gets the value of the opacity property.

getRight

Gets the value of the right property.

getShadowColor

Gets the value of the shadowColor property. (iPhone, iPad only.)

getShadowOffset

Gets the value of the shadowOffset property. (iPhone, iPad only.)

getSize

Gets the value of the size property.

getSoftKeyboardOnFocus

Gets the value of the softKeyboardOnFocus property. (Android only.)

getText

Gets the value of the text property.

getTextAlign

Gets the value of the textAlign property.

getTextid

Gets the value of the textid property.

getTop

Gets the value of the top property.

getTouchEnabled

Gets the value of the touchEnabled property.

getTransform

Gets the value of the transform property. (Android, iPhone, iPad only.)

getVisible

Gets the value of the visible property.

getWidth

Gets the value of the width property.

getWordWrap

Gets the value of the wordWrap property. (Android, Mobile Web only.)

getZIndex

Gets the value of the zIndex property.

hide

Hides this view.

remove

Removes a child view from this view's hierarchy.

removeEventListener

Removes the specified callback as an event listener for the named event.

setAnchorPoint

Sets the value of the anchorPoint property. (iPhone, iPad only.)

setAutoLink

Sets the value of the autoLink property. (Android only.)

setBackgroundColor

Sets the value of the backgroundColor property.

setBackgroundDisabledColor

Sets the value of the backgroundDisabledColor property. (Android only.)

setBackgroundDisabledImage

Sets the value of the backgroundDisabledImage property. (Android only.)

setBackgroundFocusedColor

Sets the value of the backgroundFocusedColor property. (Android only.)

setBackgroundFocusedImage

Sets the value of the backgroundFocusedImage property. (Android only.)

setBackgroundGradient

Sets the value of the backgroundGradient property. (iPhone, iPad, Mobile Web only.)

setBackgroundImage

Sets the value of the backgroundImage property.

setBackgroundLeftCap

Sets the value of the backgroundLeftCap property. (iPhone, iPad only.)

setBackgroundPaddingBottom

Sets the value of the backgroundPaddingBottom property. (iPhone, iPad only.)

setBackgroundPaddingLeft

Sets the value of the backgroundPaddingLeft property. (iPhone, iPad only.)

setBackgroundPaddingRight

Sets the value of the backgroundPaddingRight property. (iPhone, iPad only.)

setBackgroundPaddingTop

Sets the value of the backgroundPaddingTop property. (iPhone, iPad only.)

setBackgroundSelectedColor

Sets the value of the backgroundSelectedColor property. (Android, Mobile Web only.)

setBackgroundSelectedImage

Sets the value of the backgroundSelectedImage property. (Android, Mobile Web only.)

setBackgroundTopCap

Sets the value of the backgroundTopCap property. (iPhone, iPad only.)

setBorderColor

Sets the value of the borderColor property.

setBorderRadius

Sets the value of the borderRadius property.

setBorderWidth

Sets the value of the borderWidth property.

setBottom

Sets the value of the bottom property.

setCenter

Sets the value of the center property.

setColor

Sets the value of the color property.

setEllipsize

Sets the value of the ellipsize property. (Android only.)

setFocusable

Sets the value of the focusable property. (Android only.)

setFont

Sets the value of the font property.

setHeight

Sets the value of the height property.

setHighlightedColor

Sets the value of the highlightedColor property. (iPhone, iPad only.)

setHtml

Sets the value of the html property. (Android, Mobile Web only.)

setKeepScreenOn

Sets the value of the keepScreenOn property. (Android only.)

setLayout

Sets the value of the layout property.

setLeft

Sets the value of the left property.

setMinimumFontSize

Sets the value of the minimumFontSize property. (iPhone, iPad only.)

setOpacity

Sets the value of the opacity property.

setRight

Sets the value of the right property.

setShadowColor

Sets the value of the shadowColor property. (iPhone, iPad only.)

setShadowOffset

Sets the value of the shadowOffset property. (iPhone, iPad only.)

setSize

Sets the value of the size property.

setSoftKeyboardOnFocus

Sets the value of the softKeyboardOnFocus property. (Android only.)

setText

Sets the value of the text property.

setTextAlign

Sets the value of the textAlign property.

setTextid

Sets the value of the textid property.

setTop

Sets the value of the top property.

setTouchEnabled

Sets the value of the touchEnabled property.

setTransform

Sets the value of the transform property. (Android, iPhone, iPad only.)

setVisible

Sets the value of the visible property.

setWidth

Sets the value of the width property.

setWordWrap

Sets the value of the wordWrap property. (Android, Mobile Web only.)

setZIndex

Sets the value of the zIndex property.

show

Makes this view visible.

toImage

Returns an image of the rendered view, as a Blob. (Android, iPhone, iPad only.)

Properties

Name Type Summary
anchorPoint Point

Anchor point where animation should occur, relative to the view's boundaries. (iPhone, iPad only.)

animatedCenterPoint Point

Current position of the view during an animation. (Android, iPhone, iPad only.) read-only

autoLink Number

Automatically convert certain text items in the label to clickable links. (Android only.)

backgroundColor String

Background color of the view.

backgroundDisabledColor String

Disabled background color of the view. (Android only.)

backgroundDisabledImage String

Disabled background image for the view, specified as a local file path or URL. (Android only.)

backgroundFocusedColor String

Focused background color of the view. (Android only.)

backgroundFocusedImage String

Focused background image for the view, specified as a local file path or URL. (Android only.)

backgroundGradient Gradient

A background gradient for the view. (iPhone, iPad, Mobile Web only.)

backgroundImage String

Background image for the view, specified as a local file path or URL.

backgroundLeftCap Number

Size of the left end cap. (iPhone, iPad only.)

backgroundPaddingBottom Number

Number of pixels to extend the background image past the label on the bottom. (iPhone, iPad only.)

backgroundPaddingLeft Number

Number of pixels to extend the background image past the label on the left. (iPhone, iPad only.)

backgroundPaddingRight Number

Number of pixels to extend the background image past the label on the right. (iPhone, iPad only.)

backgroundPaddingTop Number

Number of pixels to extend the background image past the label on the top. (iPhone, iPad only.)

backgroundSelectedColor String

Selected background color of the view. (Android, Mobile Web only.)

backgroundSelectedImage String

Selected background image url for the view, specified as a local file path or URL. (Android, Mobile Web only.)

backgroundTopCap Number

Size of the top end cap. (iPhone, iPad only.)

borderColor String

Border color of the view.

borderRadius Number

Border radius of the view.

borderWidth Number

Border width of the view.

bottom Number or String

View's bottom position, in platform-specific units.

center Point

View's center position, in the parent view's coordinates.

color String

Color of the label text.

ellipsize Boolean

Turn on/off the addition of ellipses at the end of the label if the text is too large to fit. (Android only.)

focusable Boolean

Whether view should be focusable while navigating with the trackball. (Android only.)

font Font

Font to use for the label text.

height Number or String

View height, in platform-specific units.

highlightedColor String

Color of the label when in the highlighted state. (iPhone, iPad only.)

html String

Simple HTML formatting. (Android, Mobile Web only.)

keepScreenOn Boolean

Whether to keep the device screen on. (Android only.)

layout String

Specifies how the view positions its children. One of: 'absolute', 'vertical', or 'horizontal'.

left Number or String

View's left position, in platform-specific units.

minimumFontSize Number

Minimum font size when the font is sized based on the contents. (iPhone, iPad only.)

opacity Number

Opacity of this view, from 0.0 (transparent) to 1.0 (opaque).

right Number or String

View's right position, in platform-specific units.

shadowColor String

Text shadow color. (iPhone, iPad only.)

shadowOffset Object

Shadow offset as a dictionary with the properties x and y. (iPhone, iPad only.)

size Object

Size of the view as a dictionary of width and height properties.

softKeyboardOnFocus Number

Determines keyboard behavior when this view is focused. (Android only.)

text String

Label text.

textAlign String or Number

Text alignment, specified using one of the Titanium.UI text alignment constants: TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER, or TEXT_ALIGNMENT_RIGHT.

textid String

Key identifying a string from the locale file to use for the label text.

top Number or String

The view's top position.

touchEnabled Boolean

Whether view should receive touch events.

transform Titanium.UI.2DMatrix or Titanium.UI.iOS.3DMatrix

Transformation matrix to apply to the view. (Android, iPhone, iPad only.)

visible Boolean

Boolean value indicating whether the view is visible.

width Number or String

View's width, in platform-specific units.

wordWrap Boolean

Enable or disable word wrapping in the label. (Android, Mobile Web only.)

zIndex Number

Z index position relative to other sibling views.

Events

Name Summary
click

Fired when the device detects a click against the view.

dblclick

Fired when the device detects a double click against the view.

doubletap

Fired when the device detects a double tap against the view. (Android, iPhone, iPad only.)

longclick

Fired when the device detects a long click. (Android only.)

longpress

Fired when the device detects a long press. (Android, iPhone, iPad only.)

pinch

Fired when the device detects a pinch gesture.

singletap

Fired when the device detects a single tap against the view.

swipe

Fired when the device detects a swipe gesture (left or right) against the view. (iPhone, iPad, Mobile Web only.)

touchcancel

Fired when a touch event is interrupted by the device.

touchend

Fired when a touch event is completed.

touchmove

Fired as soon as the device detects movement of a touch.

touchstart

Fired as soon as the device detects a touch gesture.

twofingertap

Fired when the device detects a two-finger tap against the view.