You need to declare android:actionBarItemBackground
attribute which is a:
Custom item state list drawable background for action bar items.
Then, in your styles do as follows:
<style name="CustomStyle" parent="@style/Theme.Holo.Light" >
<item name="android:actionBarItemBackground">@drawable/ab_item_background</item>
<item name="actionBarItemBackground">@drawable/ab_item_background</item>
</style>
So, put your own drawable with a selector
and every state (pressed, focused, disabled, etc) to have the expected background. For example, the drawable ab_item_background.xml
declared above might be like this:
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<!-- focused/pressed: color=red -->
<item
android:state_focused="true"
android:state_pressed="true"
android:drawable="@color/red" />
<!-- pressed: color=red -->
<item
android:state_pressed="true"
android:drawable="@color/red" />
<!-- normal: color=transparent -->
<item
android:drawable="@android:color/transparent" />
</selector>
In Styling the Action Bar, you can find all the customization possibles and all the attributes to do so.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…