You are reading 12.5.1. See this page in 13.4.1.
Titanium.UI.Tab
Extends Titanium.UI.ViewTitanium.Proxy
A tab instance for a TabGroup.
A TabGroup tab instance. Each tab includes a button and one or more windows, which
holds the "contents" of the tab. Users can select a tab by clicking on the tab button.
Use the Titanium.UI.createTab method or <Tab> Alloy element to create a tab.
Use TabGroup.setActiveTab to switch between tabs in a tab group.
The behavior of tabs and tab groups follows the platform's native navigation style, which varies significantly between platforms.
iOS Platform Implementation Notes
On iOS, the tab maintains a stack of windows. Windows on top of the stack can partially or totally obscure windows lower in the stack. Calling open opens a new window on top of the window stack. When a window is closed, either by the user or by code, the window is removed from the stack, making the previous window visible. The root tab window cannot be removed.
On iOS the tab controls are generally kept on screen to allow a user to
navigate inside the app. Tab controls are hidden when the user is performing a modal
task (for example, composing a message). In this case, the app should provide a button
in the navigation bar to return to the previous screen. On iOS, the window should also
be opened as modal. On iOS, The tab controls can also be hidden by opening the new window
with tabBarHidden set to true.
When closing a tab window in iOS, you should always use the Tab.close method to ensure that the tab group maintains its navigation state.
Android Platform Implementation Notes
On Android, the tab does not maintain a stack of windows. Calling open opens a new, heavyweight window, which by default covers the tab group entirely. This seems quite different from the iOS model, but it is the standard model for Android applications. Users can use the Back button to close the window and return to the tab group.
On Android, tab windows can be closed using either
Tab.close or Window.close. Since
no window stack is maintained, only a single window opened using
Tab.open can be closed using Tab.close.
As on iOS, the root tab window cannot be closed.
Examples
Simple Tab Example
In this example, we create a simple tab and add it to a tab group.
var window = Ti.UI.createWindow({
title: 'My Tab'
});
var tab = Ti.UI.createTab({
window: window,
title: 'My Tab',
icon: 'myicon.png'
});
tabGroup.addTab(tab);
Alloy XML Markup
Previous example an an Alloy view.
<Alloy>
<TabGroup id="tabGroup">
<Tab id="tab" title="My Tab" icon="myicon.png">
<Window id="window" title="My Tab" />
</Tab>
</TabGroup>
</Alloy>
Properties 55
Inherited from Titanium.UI.View
Boolean value to remove the long press notification for the device's accessibility service.
Default: true
true if this tab is active, false if it is not.
The tab can be activated by setting the property, but since this property is platform-specific, using TabGroup.setActiveTab is recommended instead.
Icon URL for this tab when active.
If unspecified, iOS uses a tint color to indicate the active tab. See icon for more information.
If the icon provided is larger than [30 pixels (60 pixels for retina, 90 pixels for super-retina)] (https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/image-size-and-resolution/), this image will be scaled to fit.
Defines if the active icon property of the tab must be used as a mask.
This is the equivalent of the iconIsMask property, but for the active icon. When this is true, the active icon is tinted with the color specified in tabsTintColor. When this is false the image is rendered as is, though the title of the tab is still tinted.
Default: true
Defines the color of the tab icon when it is active.
Defines the color of the title of tab when it's active.
The color of the title of the tab when it's active.
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Sets the color of the tab when it is inactive.
For information about color values, see the "Colors" section of Titanium.UI.
Inherited from Titanium.UI.View
Disabled background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Disabled background image for the view, specified as a local file path or URL.
Sets the color of the tab when it is focused.
On the Android platform, this sets the color of the active tab and is only supported by TABS_STYLE_BOTTOM_NAVIGATION.
For information about color values, see the "Colors" section of Titanium.UI.
Inherited from Titanium.UI.View
Focused background image for the view, specified as a local file path or URL.
backgroundImage
StringInherited from Titanium.UI.View
Background image for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
Selected background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Selected background image url for the view, specified as a local file path or URL.
Badge value for this tab. null indicates no badge.
On the Android platform you will need to use a Theme with parent="Theme.MaterialComponents.*"
in order to use a badge. You have to pass a number as a string. Non-numberic characters will not be displayed.
On iOS, a badge will only be shown if the tab has been assigned an icon. Text only tabs do not support badges.
If this item displays a badge, this color will be used for the badge's background. If set to null, the default background color will be used instead.
For information about color values, see the "Colors" section of Titanium.UI.
badgeColor
String | Titanium.UI.Colordeprecatedsince Android 9.3.0, iPhone 6.1.0, iPad 6.1.0, macOS 9.2.0Deprecated since 12.2.0
Use Titanium.UI.Tab.badgeBackgroundColor instead.
If this item displays a badge, this color will be used for the badge's background. If set to null, the default background color will be used instead.
For information about color values, see the "Colors" section of Titanium.UI.
Set the text color of the badge.
For information about color values, see the "Colors" section of Titanium.UI.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
Inherited from Titanium.UI.View
View's clipping behavior.
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
Inherited from Titanium.UI.View
Adds a horizontal parallax effect to the view
icon
StringIcon URL for this tab.
iOS Tab Icons
On iOS, tab icons are usually white with a transparent background. The system uses a transparent tint color to indicate whether the tab is active or inactive. In the inactive state, the tint color is based on the tab bar's color tabsBackgroundColor, which defaults to black. In the active state, the tint color is usually blue. Prior to Titanium 3.1, there was no way to override the default active icon tint.
Some icon-related features:
-
You can specify the active tab's tint color as activeTabIconTint.
-
You can set separate icon images for the active and inactive states. If activeIcon is set, then
iconis used in the inactive state, andactiveIconis used in the active state. No default tint is applied to either icon.
If the icon provided is larger than [30 pixels (60 pixels for retina, 90 pixels for super-retina)] (https://developer.apple.com/ios/human-interface-guidelines/icons-and-images/image-size-and-resolution/), this image will be scaled to fit if used with activeIcon, and cropped at the bottom otherwise.
The icon inset or outset for each edge.
Use this property for example to center an icon without providing a title. To do that, set the
insets to { top: 6 } and/or { left: 6 }. The right and bottom are calculated internally to prevent the
icon from mutating.
Default: All insets are zero.
Defines if the icon property of the tab must be used as a mask.
When this property is true, the color data of the image specified as the icon is ignored and the image is used as an alpha mask. When this is false, the color data of the image is preserved.
Default: true
id
StringInherited from Titanium.UI.View
View's identifier.
Inherited from Titanium.Proxy
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
Inherited from Titanium.UI.View
When on, animate call overrides current animation if applicable.
Inherited from Titanium.UI.View
The preview context used in the 3D-Touch feature "Peek and Pop".
Inherited from Titanium.UI.View
Background color of the wrapper view when this view is used as either Titanium.UI.ListView.pullView or Titanium.UI.TableView.headerPullView.
Defaults to undefined. Results in a light grey background color on the wrapper view.
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.
Defines the color of the tab icon.
title
StringTitle for this tab.
Defines the color of the title of tab when it's inactive.
The color of the title of the tab when it's inactive.
titleid
StringKey identifying a string from the locale file to use for the tab title. Only one of title or titleid should be specified.
Inherited from Titanium.UI.View
The default text to display in the control's tooltip.
touchEnabled
BooleanInherited from Titanium.UI.View
Determines whether view should receive touch events.
Default: true
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
viewShadowColor
String | Titanium.UI.Colorsince Android 11.1.0, iPhone 3.3.0, iPad 3.3.0, macOS 9.2.0Inherited from Titanium.UI.View
Determines the color of the shadow.
Inherited from Titanium.UI.View
Determines the offset for the shadow of the view.
Inherited from Titanium.UI.View
Determines the blur radius used to create the shadow.
Root-level tab window. All tabs must have at least one root-level tab window.
Methods 14
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.
Closes the top-level window for this tab.
On iOS, this method should be used when closing a window opened from a tab, to correctly maintain the iOS tab group's navigation state. Note that the window to be closed must be passed in as a parameter:
myTab.close(tabWin);
On Android, this method does not take a window parameter.
myTab.close();
On Android, if a window has been opened in front of the tab using Tab.open,
a subsequent call to Tab.close is equivalent to calling close on that window.
No window stack is maintained, so only the most-recently opened window on a given
tab can be closed in this way.
All platforms accept an optional options parameter. The only supported property
for this dictionary is the animated flag, which specifies whether the window
close should be animated. animated is true by default.
| Parameters | Type | Description |
|---|---|---|
| window | Titanium.UI.Window | Window to close. This parameter must be omitted on Android. |
| options? | Object | Dictionary of display and animation settings to use when closing the window.
Identical to the |
convertPointToView
since Android 1.8, iPhone 1.8, iPad 1.8, macOS 9.2.0Inherited from Titanium.UI.View
Translates a point from this view's coordinate system to another view's coordinate system.
| Parameters | Type | Description |
|---|---|---|
| point | Point | A point in this view's coordinate system. If this argument is missing an |
| destinationView | Titanium.UI.View | View that specifies the destination coordinate system to convert to. If this argument is not a view, an exception will be raised. |
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 |
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
|
Opens a new window.
On iOS, the new window is opened as the top window in the tab's window stack. On Android, the new window is opened as a new, heavyweight window, obscuring the tab group.
| Parameters | Type | Description |
|---|---|---|
| window | Titanium.UI.Window | Window to open. |
| options? | openWindowParams | Dictionary of display and animation settings to use when opening the window.
Identical to the |
Closes all windows that are currently opened inside the tab.
Note that only the close event of the most recently opened window is fired.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Options supporting a single |
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
|
setWindow
deprecatedDeprecated since 10.0.0
Set the value of the window property directly.
Sets the root window that appears in the tab.
You can only use this method to set the tab's root window before the TabGroup containing this tab is openened, that is, once the TabGroup is displayed, you cannot change the root window that appears in the tab.
| Parameters | Type | Description |
|---|---|---|
| window | Titanium.UI.Window | Root window of the tab. |
Inherited from Titanium.UI.View
Stops a running animation.
Inherited from Titanium.UI.View
Returns an image of the rendered view, as a Blob.
| Parameters | Type | Description |
|---|---|---|
| callback? | Callback<Titanium.Blob> | Function to be invoked upon completion. If non-null, this method will be performed asynchronously. If null, it will be performed immediately. |
| honorScaleFactor? | Boolean | Determines whether the image is scaled based on scale factor of main screen. (iOS only) When set to true, image is scale factor is honored. When set to false, the image in the blob has the same dimensions for retina and non-retina devices. |
Events 14
click
AndroidFired when this tab is clicked in the tab group.
Inherited from Titanium.UI.View
Fired when the device detects a double click against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when the device detects a double tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
focus
AndroidInherited from Titanium.UI.View
Fired when the view element gains focus.
Inherited from Titanium.UI.View
Fired when the device detects a long press.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
postlayout
since 2.0.0Inherited from Titanium.UI.View
Fired when a layout cycle is finished.
selected
since Android 3.5.1, iPhone 5.2.0, iPad 5.2.0Fired when the tab is selected.
| Event properties | Type | Description |
|---|---|---|
| index | Number | Index of the current active tab. |
| previousIndex | Number | Index of the previous active tab. |
| tab | Titanium.UI.Tab | Current active tab object. |
| previousTab | Titanium.UI.Tab | Previous active tab object. |
Inherited from Titanium.UI.View
Fired when the device detects a single tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when the device detects a swipe gesture against the view.
| Event properties | Type | Description |
|---|---|---|
| direction | String | Direction of the swipe--either 'left', 'right', 'up', or 'down'. |
| x | Number | X coordinate of the event's endpoint from the |
| y | Number | Y coordinate of the event's endpoint from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when a touch event is interrupted by the device.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when a touch event is completed.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Penciland are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired as soon as the device detects movement of a touch.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired as soon as the device detects a touch gesture.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
unselected
since Android 3.5.1, iPhone 5.2.0, iPad 5.2.0Fired when the tab is no longer selected.
| Event properties | Type | Description |
|---|---|---|
| index | Number | Index of the current active tab. |
| previousIndex | Number | Index of the previous active tab. |
| tab | Titanium.UI.Tab | Current active tab object. |
| previousTab | Titanium.UI.Tab | Previous active tab object. |