SelectableItemBackground不使用操作栏样式

时间:2014-06-10 07:08:57

标签: android android-actionbar android-styles android-custom-attributes

我正在尝试更改操作栏上可操作项目的命中状态颜色。在我的nexus 7(4.3)中,命中状态的默认颜色是蓝绿色。在我的nexus 4(4.4)上,命中状态是holo_light。即使在将'android:selectableItemBackground'设置为holo_light之后,我也看到按钮上的绿松石蓝色按下我的nexus 7.

这是我正在使用的代码。

 <style name="CustomActionBarStyle"    parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
    <item name="android:background">@drawable/bg_image_actionbar</item>
    <item name="android:backgroundStacked">@drawable/bg_image_actionbar_stacked</item>
    <item name="android:displayOptions">showHome|homeAsUp</item>
    <item name="android:icon">@drawable/layer_actionbar_logo</item>
    <item name="android:titleTextStyle">@style/ActionBarTitleTextStyle</item>
    <item name="android:selectableItemBackground">@drawable/selector_custom_action_bar_selectable_item_bg</item>
 </style>  

自定义选择器的xml是

<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
    <item android:state_focused="true"  android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_disabled_holo_light" />
    <item android:state_focused="true"  android:state_enabled="false"                              android:drawable="@drawable/list_selector_disabled_holo_light" />
    <item android:state_focused="true"                                android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
    <item android:state_focused="false"                               android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_light" />
    <item android:state_focused="true"                                                             android:drawable="@drawable/list_pressed_holo_light" />
    <item                                                                                          android:drawable="@android:color/transparent" />
</selector>  

有人可以指出我在这里缺少什么吗?

1 个答案:

答案 0 :(得分:0)

最后解决了这个问题。我不得不添加另一个样式“android:listViewStyle”

相关问题