How can I change the touch affect color of Actions with ActionBarSherlock?

拟墨画扇 提交于 2019-12-24 03:40:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!