Android 5.0 Deprecation: splitActionBarWhenNarrow
UPDATE: If your app specifically uses
themes inheriting from it),
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
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
no longer splits the action bar, on Android 5.0+.
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:
actionViewClassfor items and do not have a suitable
onOptionsItemSelected()handler for the scenario
You assumed that your action item with the
ProgressBaror the like would always be visible, so users now no longer realize that some background operation is going on
You assumed that your
actionLayoutwould 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
appears to be tricky, and the
Toolbar approach will not work
prior to API Level 21 (unless you’re going the route of using
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! Learn more!