简体   繁体   中英

Android action bar item custom background

I'm using ActionBarSherlock and I'm trying to set a custom background on the action bar items.

I've tried:

    <item name="actionButtonStyle">@style/customActionButtonStyle</item>
    <item name="android:actionButtonStyle">@style/customActionButtonStyle</item>
</style>

<style name="customActionButtonStyle" parent="Widget.Sherlock.Light.ActionButton">
    <item name="android:background">@drawable/background_black_translucent</item>
</style>

and

<item name="android:selectableItemBackground">@drawable/background_black_translucent</item>
<item name="selectableItemBackground">@drawable/background_black_translucent</item>

<item name="android:actionBarItemBackground">@drawable/background_black_translucent</item>
<item name="actionBarItemBackground">@drawable/background_black_translucent</item>

but I can't get it to work. Any ideas?

Thanks

I actually got it to work by setting the selectable item background property:

<style name="MyTheme" parent="@android:style/Theme.Sherlock.Light">
    <item name="android:selectableItemBackground">@drawable/background_action_item</item>
    <item name="selectableItemBackground">@drawable/background_action_item</item>
</style>

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM