Titanium.UI.ImageView

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

Summary

An Image View is used to display an image or a series of images in an animation.

Description

If you specify a width and/or height property for the image view, the image will be scaled to fit into this space while maintaining its original aspect ratio.

Use the Titanium.UI.createImageView method to create an image view.

Code Examples

Basic Image View

In this example, we create a simple image view:

var image = Titanium.UI.createImageView({url:'myimage.png'});
view.add(image);

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.

hide

Hides this view.

pause

Pause a running animation. (Android, iPhone, iPad only.)

remove

Removes a child view from this view's hierarchy.

removeEventListener

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

show

Makes this view visible.

start

Start the image animation. This method only works if you set multiple images. (Android, iPhone, iPad only.)

stop

Stop a running animation and reset the index to the first image. (Android, iPhone, iPad only.)

toBlob

Return the image as a Blob object. (Android, iPhone, iPad only.)

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

animating Boolean

true if the animation is running. read-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.)

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.

canScale Boolean

Allow the user to scale the image (using pinch-zoom or the optional zoom controls). (Android only.)

center Point

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

decodeRetries Number

Number of times to retry decoding the bitmap at this URL. (Android only.)

defaultImage String

url to the default image to display while loading a remote image

duration Number

amount of time in milliseconds to animate one cycle

enableZoomControls Boolean

Show zoom controls when the user touches the image view. (Android only.)

focusable Boolean

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

height Number or String

View height, in platform-specific units.

hires Boolean

Indicates whether or not the source image is in 2x resolution for Retina displays. Use for remote images ONLY. (iPhone, iPad, Mobile Web only.)

image String or Titanium.Blob or Titanium.Filesystem.File

Image to display. Specify using a local file path or URL, or pass a Blob or File object containing image data.

images Array<Object>

Array of images to display in an animation. Accepts the same types as image.

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.

opacity Number

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

paused Boolean

Boolean value indicating if the animation is paused. read-only

preventDefaultImage Boolean

Set to true to disable display of the default image while loading a remote image.

repeatCount Number

Number of times to repeat the image animation.

reverse Boolean

Boolean value indicating if the animation should happen in reverse (from last to first).

right Number or String

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

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

top Number or String

The view's top position.

touchEnabled Boolean

Whether view should receive touch events.

transform Object

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

url String

Deprecated URL to the image to display. Deprecated: use image instead.

visible Boolean

Boolean value indicating whether the view is visible.

width Number or String

View's width, in platform-specific units.

zIndex Number

the z index position relative to other sibling views

Events

Name Summary
change

Fired for each frame changed during an animation.

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

error

Fired when an image fails to load.

load

Fired when either the initial image and/or all of the images in an animation are loaded.

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.

start

Fired when the animation starts.

stop

Fired when the animation stops.

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.