问题
I have several actions all of which display properly. When I click the actions however, the color comes up as the default blueish color and it looks awful with my app. How can I change the 'selected' color of the Action?
This is basically a duplicate of this question, except that one doesn't deal with ActionBarSherlock.
EDIT
Using the accepted answer, I am getting this error after adjusting style.xml
The error is error: Error retrieving parent for item: No resource found that matches given name 'Theme'.
I entered it into my style.xml
file exactly as given below. In the Sherlock library /res/values/abs_themes.xml
file the style name matches mine exactly.
回答1:
Well, ABS uses (almost) the same API as the default ActionBar so just change the theme of the (duplicate) answer like this:
<style name="myStyle" parent="Theme.Sherlock">
<item name="android:selectableItemBackground">@android:drawable/item_background_holo_dark</item>
<item name="selectableItemBackground">@android:drawable/item_background_holo_dark</item>
</style>
And the drawable:
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:exitFadeDuration="@android:integer/config_mediumAnimTime">
<item android:drawable="@drawable/list_selector_disabled_holo_dark" android:state_enabled="false" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/list_selector_disabled_holo_dark" android:state_enabled="false" android:state_focused="true"/>
<item android:drawable="@drawable/list_selector_background_transition_holo_dark" android:state_focused="true" android:state_pressed="true"/>
<item android:drawable="@drawable/list_selector_background_transition_holo_dark" android:state_focused="false" android:state_pressed="true"/>
<item android:drawable="@drawable/list_focused_holo" android:state_focused="true"/>
<item android:drawable="@color/transparent"/>
</selector>
You just inherit your styles from Theme.Sherlock
and set an other selectableItemBackground
attribute, but without the android:
in front.
来源:https://stackoverflow.com/questions/14507587/how-can-i-change-the-touch-affect-color-of-actions-with-actionbarsherlock