/var/log

Change Android homeAsUpIndicator icon in Titanium

For a project I wanted to show a hamburger menu icon in the main screen that shows a navigation drawer. The steps I did:

I manually enabled the displayHomeAsUp property of the ActionBar and handled the onHomeIconItemSelected event to show the navigation drawer:

$.mainWindow.activity.actionBar.displayHomeAsUp = true;
$.mainWindow.activity.actionBar.onHomeIconItemSelected = function() {
  onMenu();
};

And also replaced the "back" arrow icon:

<style name="ThemeHomeWindow" parent="Theme.AppCompat.Light">
  <item name="android:homeAsUpIndicator">@drawable/hamburgermenu</item>
</style>

And I set the theme in the Allow XML:

<Alloy>
  <Window onOpen="onOpen" theme="ThemeHomeWindow"></Window>
</Alloy>

 

Tag: , | Category: