Making Android Beautiful with ActionBarSherlock

September 10, 2012 Pivotal Labs

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.

About the Author

Biography

Previous
Live Streaming without a YouTube Partner Account
Live Streaming without a YouTube Partner Account

The need to live stream across multiple platforms is becoming a necessity with everyone having different pr...

Next
09/10/12: "We need it to work differently"
09/10/12: "We need it to work differently"

Helps SQLite gem on Heroku Don't even try, or any other ideas? Caching individual files on nginx Seems yo...