how to override pressed state color in sherlock ac

2019-08-01 13:59发布

问题:

I implemented sherlock actionbar in my app which has dark green action bar .. #008000. when i press the action bar button it turns out ics blue (default) color...how to turns out green when i press action bar button?.

IN themes.xml i am using this.

       <resources>
<style name="Theme.Styled" parent="Theme.Sherlock.Light">
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
 <item name="actionBarItemBackground">@drawable/selector</item>
</style>
<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="background">#008000</item>
    <item name="android:background">#008000</item>

    <item name="backgroundSplit">@drawable/bg_striped_split</item>
    <item name="android:backgroundSplit">@drawable/bg_striped_split</item>


</style>

in drawable selector.xml

<item android:state_pressed="true" android:drawable="@drawable/pressed" />
<item android:state_focused="true" android:drawable="@drawable/focused" />
<item android:drawable="@android:color/transparent" />


in drawable pressed.xml

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

         <solid android:color="#690"></solid>

     </shape>

回答1:

add this in your style

       <item name="android:actionBarItemBackground">@drawable/selector</item>