我试图改变动作栏上可操作项目的点击状态颜色。在我的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>
谁能指出我在这里错过了什么?
终于修复了这个问题。我必须添加另一个样式"android:listViewStyle"