Titanium.UI.ActivityIndicator
Extends Titanium.UI.ViewTitanium.Proxy
An activity indicator that lets the user know an action is taking place.
| Android | iOS |
|---|---|
![]() |
![]() |
An activity indicator can be used to show the progress of an operation in the UI to let the user know that some action is taking place. An activity indicator consists of a spinning animation and an optional text message, and is used to indicate an ongoing activity of indeterminate length. To show progress, use Titanium.UI.ProgressBar instead.
Use the Titanium.UI.createActivityIndicator method or <ActivityIndicator> Alloy element to
create an ActivityIndicator object.
ActivityIndicator is a view and, like any view, must be added to a window or other top-level
view before it can be shown. Unlike most views, ActivityIndicator is hidden by
default and must be shown explicitly by calling its Titanium.UI.ActivityIndicator.show method.
Examples
Simple Activity Indicator
Open a yellow window immediately after a blue window. Show an activity indicator while some code executes and hide it on completion. Then close the yellow window.
Ti.UI.backgroundColor = 'white';
var win1 = Ti.UI.createWindow({
backgroundColor: 'blue'
});
var win2 = Ti.UI.createWindow({
backgroundColor: 'yellow'
});
var activityIndicator = Ti.UI.createActivityIndicator({
color: 'green',
message: 'Loading ...',
style: Ti.UI.ActivityIndicatorStyle.DARK,
top: 10,
left: 10,
height: Ti.UI.SIZE,
width: Ti.UI.SIZE
});
// The activity indicator must be added to a window or view for it to appear
win2.add(activityIndicator);
// eventListeners must always be loaded before the event is likely to fire
// hence, the open() method must be positioned before the window is opened
win2.addEventListener('open', function (e) {
activityIndicator.show();
// do some work that takes 6 seconds
// ie. replace the following setTimeout block with your code
setTimeout(function() {
e.source.close();
activityIndicator.hide();
}, 6000);
});
win1.open();
win2.open();
Alloy XML Markup
Previous example as two Alloy views.
win1.xml:
<Alloy>
<Window onOpen="openWin2" backgroundColor="blue" />
</Alloy>
win1.js:
function openWin2 () {
var win2 = Alloy.createController('win2').getView();
win2.open();
}
win2.xml:
<Alloy>
<Window onOpen="showIndicator" backgroundColor="yellow">
<!-- Define the styling properties in the TSS file -->
<ActivityIndicator id="activityIndicator" message="Loading..."/>
</Window>
</Alloy>
win2.js:
function showIndicator(e) {
$.activityIndicator.show();
// do some work that takes 6 seconds
// ie. replace the following setTimeout block with your code
setTimeout(function() {
e.source.close();
$.activityIndicator.hide();
}, 6000);
}
Properties 36
Inherited from Titanium.UI.View
Boolean value to remove the long press notification for the device's accessibility service.
Default: true
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
bottom
Number | StringBottom position of the view.
Determines the absolute position of the view relative to its parent.
Can be either a float value or a dimension string (for example 100 or '50%'.)
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
color
String | Titanium.UI.ColorColor of the message text, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
Inherited from Titanium.UI.View
Base elevation of the view relative to its parent in pixels.
Inherited from Titanium.UI.View
Discards touch related events if another app's system overlay covers the view.
Default: false
Font used for the message text.
height
StringWidth of the view. Only accepts value of Titanium.UI.SIZE, which must be explicitly set in order to display the message and to position the view correctly.
Inherited from Titanium.UI.View
Adds a horizontal parallax effect to the view
id
StringInherited from Titanium.UI.View
View's identifier.
Color of the animated indicator.
For information about color values, see the "Colors" section of Titanium.UI.
Default: white
Inherited from Titanium.UI.View
A value indicating the render mode of the View
Default: false
left
Number | StringLeft position of the view.
Determines the absolute position of the view relative to its parent.
Can be either a float value or a dimension string (for example 100 or '50%'.)
Inherited from Titanium.Proxy
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
message
StringMessage text.
messageid
StringKey identifying a string in the locale file to use for the message text.
Only one of message or messageid should be specified.
Inherited from Titanium.UI.View
The preview context used in the 3D-Touch feature "Peek and Pop".
right
Number | StringRight position of the view.
Determines the absolute position of the view relative to its parent.
Can be either a float value or a dimension string (for example 100 or '50%'.)
Inherited from Titanium.UI.View
Clockwise 2D rotation of the view in degrees.
Inherited from Titanium.UI.View
Clockwise rotation of the view in degrees (x-axis).
Inherited from Titanium.UI.View
Clockwise rotation of the view in degrees (y-axis).
Inherited from Titanium.UI.View
Scaling of the view in x-axis in pixels.
Inherited from Titanium.UI.View
Scaling of the view in y-axis in pixels.
style
NumberThe style for the activity indicator.
One of the activity indicator style constants.
See also: indicatorColor
Default: <Titanium.UI.ActivityIndicatorStyle.PLAIN>
Inherited from Titanium.UI.View
The default text to display in the control's tooltip.
top
Number | StringTop position of the view.
Determines the absolute position of the view relative to its parent.
Can be either a float value or a dimension string (for example 100 or'50%'.)
Inherited from Titanium.UI.View
A material design visual construct that provides an instantaneous visual confirmation of touch point.
Default: false
Inherited from Titanium.UI.View
Optional touch feedback ripple color. This has no effect unless touchFeedback is true.
Inherited from Titanium.UI.View
A name to identify this view in activity transition.
Inherited from Titanium.UI.View
Horizontal location of the view relative to its left position in pixels.
Inherited from Titanium.UI.View
Vertical location of the view relative to its top position in pixels.
Inherited from Titanium.UI.View
Depth of the view relative to its elevation in pixels.
Inherited from Titanium.UI.View
Adds a vertical parallax effect to the view
width
StringWidth of the view. Only accepts value of Titanium.UI.SIZE, which must be explicitly set in order to display the message and to position the view correctly.
Methods 10
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Inherited from Titanium.UI.View
Removes all previously added motion effects.
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
getViewById
since 6.1.0Inherited from Titanium.UI.View
Returns the matching view of a given view ID.
| Parameters | Type | Description |
|---|---|---|
| id | String | The ID of the view that should be returned. Use the |
Hides the activity indicator and stops the animation.
insertAt
since 3.3.0Inherited from Titanium.UI.View
Inserts a view at the specified position in the children array.
| Parameters | Type | Description |
|---|---|---|
| params | ViewPositionOptions | Pass an object that specifies the view to insert and optionally at which position (defaults to end) 2 fields
|
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Shows the activity indicator and starts the animation.
Remember to add the activity indicator to a parent view first, so it centers properly. This is optional for Android and required for iOS.
Inherited from Titanium.UI.View
Stops a running animation.
Events 1
rotate
since 12.7.0Inherited from Titanium.UI.View
Fired when the device detects a two finger rotation.
| Event properties | Type | Description |
|---|---|---|
| rotate | Number | Rotation in degrees. |

