I am using AppCompat and have successfully implemented the new action bar that rolled out with lollipop. The only problem is the pressed background color of the action items. I want to show a different background color for the action item when pressed. Any idea how it can be done?
You have a couple of options. But first, some background:
The action items in AppCompat use theme attribute ?attr/actionBarItemBackground (see res/values/styles_base.xml) which is set to ?attr/selectableItemBackgroundBorderless (see res/styles/themes_base.xml) by default. This attribute is set to a borderless ripple on L and @drawable/abc_item_background_holo_light on previous versions.
The action bar itself is themed by setting ?attr/actionBarTheme (themes_base.xml) and is set to @style/ThemeOverlay.AppCompat.ActionBar by default. On Holo, this theme overrides the actionBarItemBackground, so you'll need to make your changes here.
So, the easy way to override the action item background for all action bars would be to set actionBarItemBackground in your actionBarTheme. You'll probably also want to override selectableItemBackground since the CloseMode item doesn't use actionBarItemBackground (no idea why).
values/styles.xml:
<style name="MyAppTheme" parent="Theme.AppCompat">
...
<item name="actionBarTheme">@style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="ThemeOverlay.AppCompat.ActionBar">
...
<item name="actionBarItemBackground">@drawable/whatever_you_want</item>
<item name="selectableItemBackground">@drawable/whatever_you_want</item>
</style>
Note: These changes apply to all API levels, so if you still want ripples on API 21+, you'll want both drawable and drawable-v21 versions of @drawable/whatever_you_want, the latter of which incorporates ripples.