The CommonsBlog


Android 5.0 Deprecation: splitActionBarWhenNarrow

UPDATE: If your app specifically uses Theme.Holo (or themes inheriting from it), splitActionBarWhenNarrow continues to work on Android 5.0. If you are using Theme.Material — whether explicitly or because you did not specify a theme — then splitActionBarWhenNarrow no longer works.

Gosh, it would be nice if deprecated features were actually documented as deprecated.

Alas, in the case of splitActionBarWhenNarrow, this capability was quietly dropped in Android 5.0, but the documentation does not mention this. This goes beyond standard deprecation (“we think that there is a better solution that we would like you to use, but we will support this for the foreseeable future”). This is out-and-out “dead-ification”: splitActionBarWhenNarrow no longer splits the action bar, on Android 5.0+.

Of course, splitActionBarWhenNarrow was never a guarantee, and certain devices and configurations would not split the action bar. For many apps, therefore, the only real impact will be with aesthetics, where now a bunch of action bar items wind up in the overflow in narrow scenarios, instead of being visible on the split action bar.

Where the problem becomes much greater is if you were more significantly relying upon action bar items being directly visible:

  • You used actionLayout or actionViewClass for items and do not have a suitable onOptionsItemSelected() handler for the scenario

  • You assumed that your action item with the ProgressBar or the like would always be visible, so users now no longer realize that some background operation is going on

  • You assumed that your actionLayout would always be inflated and therefore crash when it is not inflated

  • And so on

While the official answer appears to be to use a bottom-aligned Toolbar, getting a look equivalent to splitActionBarWhenNarrow appears to be tricky, and the Toolbar approach will not work prior to API Level 21 (unless you’re going the route of using appcompat_v7, which has its own issues).

Again, Google is welcome to change whatever it wants, whenever it wants in Android. It is Google’s platform. It would just be nice if Google would actually tell people when they deprecate this sort of thing.


Need Android app development training for your team? Mark Murphy has trained hundreds of developers! Learn more!