如何重写夏洛克操作栏按下状态的颜色吗?(how to override pressed state

2019-10-18 10:41发布

我实现了大侦探动作条在我的应用程序,它有深绿色行动吧..#008000。 当我按操作栏按钮原来的IC蓝色(默认)颜色...如何原来绿色当我按下动作栏按钮?

IN的themes.xml我使用这一点。

       <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>

在绘制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" />


在绘制pressed.xml

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

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

     </shape>

Answer 1:

在样式添加此

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


文章来源: how to override pressed state color in sherlock action bar?