0

我不明白如何更改 ActionBarSherlock 中按下项目的颜色。我正在覆盖主题Widget.Sherlock.Light.ActionBar.Solid.Inverse,当我查看这个主题的来源时,我找不到我的项目在按下时所具有的蓝色。有人能帮我吗?

4

1 回答 1

1

有一个样式属性负责 ActionButton 背景:actionBarItemBackground。只需将您自己定义的 DrawableStateList 设置为一个值。

例如,这是默认的 DrawableStateList:

<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/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true"  android:state_enabled="false"                              android:drawable="@drawable/abs__list_selector_disabled_holo_dark" />
<item android:state_focused="true"                                android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_dark" />
<item android:state_focused="false"                               android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_dark" />
<item android:state_focused="true"                                                             android:drawable="@drawable/abs__list_focused_holo" />
<item                                                                                          android:drawable="@android:color/transparent" />

于 2012-06-21T21:46:17.377 回答