How can I change the touch effect color of the ActionBar in Android 3.0 and higher

前端 未结 1 1940
长发绾君心
长发绾君心 2020-12-02 14:01

I am trying to change the color of the rollover effect when you touch an ActionBar Item. On my Galaxy Nexus with 4.0.2 it\'s kind of a turquoise color shading which I want t

相关标签:
1条回答
  • 2020-12-02 14:27

    The native action bar uses the theme attribute selectableItemBackground for action item background drawing. This should be a state-list drawable.

    Here's the declaration in Theme.Holo:

    <style name="Theme.Holo">
        <!-- bunch of things -->
        <item name="android:selectableItemBackground">@android:drawable/item_background_holo_dark</item>
        <!-- bunch of things -->
    </style>
    

    And its drawable XML:

    <selector xmlns:android="http://schemas.android.com/apk/res/android"
              android:exitFadeDuration="@android:integer/config_mediumAnimTime">
    
        <!-- 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/list_selector_disabled_holo_dark" />
        <item android:state_focused="true"  android:state_enabled="false"                              android:drawable="@drawable/list_selector_disabled_holo_dark" />
        <item android:state_focused="true"                                android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_dark" />
        <item android:state_focused="false"                               android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition_holo_dark" />
        <item android:state_focused="true"                                                             android:drawable="@drawable/list_focused_holo" />
        <item                                                                                          android:drawable="@color/transparent" />
    </selector>
    
    0 讨论(0)
提交回复
热议问题