android - 如何从 Sherlock 操作栏菜单项中删除蓝光?

标签 android actionbarsherlock

有谁知道如何去除围绕着被按下的操作栏菜单项的恼人的蓝光?

enter image description here

谢谢, 姆拉乔

最佳答案

是的,你可以覆盖...

android:actionBarItemBackground 

... 为每个操作项的背景定义可绘制资源。例如

<style name="CustomActivityTheme" parent="@android:style/Theme.Holo">
    <item name="android:actionBarItemBackground">@drawable/ab_item_background</item>
</style>

查看文档 here .

注意:如果您想支持 API 级别低于 14 的 Android 版本,您必须包含 support packageActionBarSherlock (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>

您还可以使用颜色代替可绘制对象,例如:

    <item name="actionBarItemBackground">@color/myColorDefinition</item>

p.s. ... 或者最好使用状态可绘制对象:

<?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> 

关于android - 如何从 Sherlock 操作栏菜单项中删除蓝光?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15705878/

相关文章:

java - Android dex 问题 : nested class + final boolean : com. android.dex.util.ExceptionWithContext

android - Activity 完成后停止android中的振动

android - Android平台有类似iOS本地Notification的等效解决方案吗?

java - 操作栏 : Center text on navigation bar buttons

android - onCreateOptionsMenu 使用 fragment 多次命中

android - ActionBarSherlock SearchView 转换错误

android - XML 中 setTag(key, value) 的等价性

Android:不可见的对象仍然可以点击

Android 3.0之前版本的action bar批量选择

android - 在 Android Studio 0.8.9 上导入 actionbarsherlock