Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

LABS
Making Android Beautiful with ActionBarSherlock

Until recently, Android design lacked definition and we had to fend for attractive apps as best we could. Now with Honeycomb and Ice Cream Sandwich, Google has shaped up and come out with an awesome design vision for the platform. For 3.0+, beauty can be native and the Action Bar is the new standard.

Yet, the majority of the Android market isn’t 3.0+, and isn’t likely to be for a while. Back-porting is time consuming, but Jake Wharton has conveniently done almost all of it for us with his ActionBarSherlock library.

Using ActionBarSherlock

To use ABS, you just extend Sherlock base activities and theme the app in your manifest. The interaction works off of a single API by calling getSupportActionBar().

public class ProfileActivity extends SherlockFragmentActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.profile);
		getSupportActionBar().setDisplayShowHomeEnabled(false);
	}
}

It uses exactly the same API as the native action bar, so just check the regular action bar documentation and guide. (So sweet)

Theming

This is the part I found most time consuming, but again its really the same as theming the native action bar. You do have to remember to create all the tags twice (ABS wasn’t able to get around that part).

Things like the Action Bar Style Generator are great for generating the right assets for this.

Bonus: There’s an additional available style called Theme.Sherlock.ForceOverflow if you want 2.x apps to have that overflow menu look.

Other Things to Note

  • All those buttons in the Action Bar come from menus
  • You can make your tabs into swiping tabs!
  • On tablets the action bar tends to behave a little differently
  • The ABS library is a superset of the compatibility library, so it supports Fragments and more

To check out exactly what ABS gives you, download the sample apk, and take a look at some of Jake Wharton’s other projects.

Comments
  1. […] thanks to an old co-worker Hannah’s blog post (Xtreme Labs Blog) I was reminded of the documentation Google puts up for Android’s design specs, which I […]