是的,你可以覆盖......
android:actionBarItemBackground
Run Code Online (Sandbox Code Playgroud)
...为每个操作项的背景定义可绘制资源.例如
<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
<item name="android:actionBarItemBackground">@drawable/ab_item_background</item>
</style>
Run Code Online (Sandbox Code Playgroud)
请查看此处的文档.
注意:如果你想支持的Android版本的API级别,你必须包括小于14 支持包和ActionBarSherlock在您的应用程序(ABS).之后你需要为Android标准和ABS设置背景:
<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
<item name="android:actionBarItemBackground">@drawable/ab_item_background</item>
<item name="actionBarItemBackground">@drawable/ab_item_background</item>
</style>
Run Code Online (Sandbox Code Playgroud)
您也可以使用颜色代替drawable,例如:
<item name="actionBarItemBackground">@color/myColorDefinition</item>
Run Code Online (Sandbox Code Playgroud)
ps ...或者最好,使用一个drawable状态:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_pressed"
android:state_pressed="true" />
<item android:drawable="@drawable/button_default" />
</selector>
Run Code Online (Sandbox Code Playgroud)