60 Flares 60 Flares ×

Appcelerator’s Android support just got better with the AppCompat library. If you remember from this post and this other one, Android apps built with Titanium didn’t have the ActionBar activated by default, and your Windows looked something like this:

/wp-content/uploads/android-plain-win-Bvd9cN4yqm.png

You then had to open up your tiapp.xml and add some lines of code to activate the proper theme that will give you the ActionBar and set it to use API Level 11 (Android 3.0), and since the ActionBar was not available to versions below 3.0, you had to rework your app’s UI to accommodate to those cases. This was not a Titanium problem though, but an Android one, which was fixed by the creation of the AppCompat Library, now supported by Titanium.

What does this mean for you? Well it means that your Android apps now support the ActionBar on devices running Android 2.1 (API Level 7) and up, and this without making any special changes to your code. For example, a simple window like this,

will give you this result.

/wp-content/uploads/actionbar_all-qO9y77lLCe.png

Your Android apps will now follow the Android’s UX guidelines, as far as the ActionBar is concerned, even on devices running old versions of Android.

Customizing and branding your Android apps

You can customize the look your ActionBar to match your app’s branding by creating custom ActionBar themes. Themes now, however, need to inherit from AppCompat and not from Holo like before. If your app was using Holo, Holo Light or Holo Light DarkActionBar, this guide shows you how to create the AppCompat equivalents.

When creating custom themes using the Android Action Bar Style Generator you simply need to make sure that you specify AppCompat compatibility as shown below.

/wp-content/uploads/abstyle-VXjrzhiEnL.png

Then download the resources like before and save them to /platform/android/res and add it to your tiapp.xml, for example:

Based on this example, your app with a custom Green ActionBar Theme will look like this:

/wp-content/uploads/abstyle_all-1ZAyvVLABK.png

Feel free to download the examples from Github and test them out yourself.

60 Flares Twitter 28 Facebook 6 Google+ 13 LinkedIn 13 Email -- 60 Flares ×