Download the latest distribution ZIP-file and consult the Titanium Documentation on how install it, or simply use the gitTio CLI:
$ gittio install com.alcoapps.actionbarextras
Please make sure that your window is open before you access the actionbar.
javascript
var abextras = require('com.alcoapps.actionbarextras');
title
(String) - sets the Actionbar title
instead of a String, you can also pass an Object with these properties:
color (String)
subtitle
(String) - sets the Actionbar subtitle
instead of a String, you can also pass an Object with these properties:
color (String)
backgroundColor
(String) - sets the Actionbar backgroundColor (Only used for the primary action bar. If you use a split action bar, you should go for a theme to set the color)
titleFont
(String | Object) - sets the Actionbar title font
subtitleFont
(String | Object) - sets the Actionbar subtitle font
titleColor
(String) - sets the Actionbar title color
subtitleColor
(String) - sets the Actionbar subtitle color
disableIcon
(Boolean) - disables / enables the Actionbar icon
homeAsUpIcon
(String) - sets the homeAsUp icon
window
(Ti.UI.Window) - Sets a reference to a window. By default, ActionbarExtras will use
the current window, but you may want to define a specific reference.
actionbarHeight
(Number) - returns the height of the Actionbar as absolute pixels
statusbarColor
(String) - sets the Color of the status bar
navigationbarColor
(String) - sets the Color of the navigation bar
elevation
(Number) - sets the Elevation of the Actionbar (in dp)
upColor
(String) - sets the color of the up icon
displayShowHomeEnabled
(Boolean) - Set whether to include the application home affordance in the action bar.
displayShowTitleEnabled
(Boolean) - Set whether an activity title/subtitle should be displayed.
displayUseLogoEnabled
(Boolean) - Set whether to display the activity logo rather than the activity icon.
setTitle( arg )
- sets the title
property
arg (Object | String) - title
setSubtitle( arg )
- sets subtitle
property
arg (Object | String) - subtitle
setBackgroundColor( arg )
- sets the backgroundColor
property
arg (String) - color
setTitleFont( arg )
- sets the titleFont
property
arg (String | Object) - font
setSubtitleFont( arg )
- sets the subtitleFont
property
arg (String | Object) - font
setTitleColor( arg )
- sets the titleColor
property
arg (String) - color
setSubtitleColor( arg )
- sets the subtitleColor
property
arg (String) - color
setDisableIcon( arg )
- sets the disableIcon
property
arg (Boolean) (optional) - enabled / disabled
setHomeAsUpIcon( arg )
- sets the homeAsUpIcon
property
arg (String) - Url to the icon
hideLogo( )
- hides the logo
setColor( arg )
- sets the color of title and subtitle
arg (String) - color
setFont( arg )
- sets the font of title and subtitle
arg (String) - color
setWindow( arg )
- sets the window property
arg (Ti.UI.Window) - window
setLogo( arg )
- sets a custom logo based on a font
args (Object):
icon
(String) - The icon to use from the iconfontfontFamily
(String) - the font to usecolor
(String) - the icon color
setMenuItemIcon( arg )
- sets a custom menu item icon based on a font
args (Object):
menu
(Ti.Android.Menu) - a reference to the menumenuItem
(Ti.Android.MenuItem) - a reference to the menu item (NOTE: You must set an itemId
on the menu item)icon
(String) - The icon to use from the iconfontfontFamily
(String) - the font to usecolor
(String) - the icon colorsize
(Number) - the icon size optional default: Actionbar icon size ( 24 dp )
addShareAction( arg )
- adds a Share action to the Actionbar
menu
(Ti.Android.Menu) - a reference to the menuintent
(Ti.Android.Intent) - sharing Intenttitle
(String) - optional default: "Share"showAsAction
(Number) - optional default: Ti.Android.SHOWASACTIONIFROOMcreateDropdown( arg )
- adds a dropdown menu to the ActionBar
titles
(String[]) - an Array of Strings, representing the dropdown itemskeepTitle
(Boolean) - if set to true, it shows both, title and dropdown, otherwise the title get replaced by the dropdown (Optional, default: false)getActionbarHeight( )
- returns the height of the Actionbar as absolute pixels
setStatusbarColor( arg )
- sets the color of the status bar
arg (String) - color
setNavigationbarColor( arg )
- sets the color of the navigation bar
arg (String) - color
setElevation( arg )
- sets the elevation property
arg (Number) - elevation
setUpColor( arg )
- sets the upColor property
arg (String) - color
setDisplayShowHomeEnabled( arg )
- sets the displayShowHomeEnabled property
arg (Boolean) - showHome
setDisplayShowTitleEnabled( arg )
- sets the displayShowTitleEnabled property
arg (Boolean) - showTitle
setDisplayUseLogoEnabled( arg )
- sets the displayUseLogoEnabled property
arg (Boolean) - useLogo
setActionbarImage( arg )
- sets the custom ActionBar layout, load the provided image and hides the title/subtitle.
arg (Object)
image
(String|Blob) - A Blob, or a valid String representing the path to the image. Note: Using the format "images/myimage.png" will load the density dependent image in the corresponding folders: /(Resources|app/assets)/android/images/res-(l|m|h|x|xx|xxx)dpi/myimage.png. If you don't care for the density, then use any other valid way to pass the image's path or Blob.
disableActionbarImage()
- Restore the title/subtitle to their previous states and hides the custom ActionBar layout.
An ActionBar Dropdown can be created with createDropdown
. Make sure you pass a String-Array as titles
property. Example:
javascript
var dropdown = abextras.createDropdown({
titles: [ "Home", "Search", "Likes", "Settings" ],
index: 1 // optional (default: 0)
});
activeItem
(Number) - the index of the current active dropdown itemremove
- removes the drop-down from the ActionBarchange
- fired when dropdown item is changedindex
(Number) - index of the selected dropdown itemYou can style an SearchView with Actionbar Extras. This is done with the method:
setSearchView( args )
- enhances an existing search view
searchView
(Ti.UI.Android.SearchView) - a reference to the search viewbackgroundColor
(String) - changes the background color of the search viewtextColor
(String) - changes the text color of the search viewhintColor
(String) - changes the hint color of the search viewline
(String) - image path to replace the line drawable used by the search viewcancelIcon
(String) - image path to use a custom close iconsearchIcon
(String) - image path to use a custom magnifier icon (or null
to remove it)maxWidth
(int) - set width of search view. Use Number.MAX_VALUE
to fill the whole action barAn example of how to use this is included in the example app.
`js
var icons = require('font-awesome');
activity.onCreateOptionsMenu = function(e) { e.menu.clear();
var createItem = e.menu.add({ itemId: 101, //unique random number showAsAction: Ti.Android.SHOWASACTION_ALWAYS });
abx.setMenuItemIcon({ menu: e.menu, menuItem: createItem, fontFamily: 'FontAwesome', icon: icons.check, color: 'white', size: 30 }) };
activity.invalidateOptionsMenu();
`