I am trying to change the color of an item when I click it. I used the actionBarItemBackground element in the style of the action bar, but nothing happens. Color has not changed ...
Here is my code:
<style name="ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar.Solid"> <item name="android:background">@color/actionbar_background</item> <item name="titleTextStyle">@style/ActionBarStyle.Title</item> <item name="actionBarItemBackground">@drawable/action_bar_item_selector</item> <item name="android:actionBarItemBackground" tools:ignore="NewApi">@drawable/action_bar_item_selector</item> </style>
And the selector:
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/pressed_item" android:state_focused="true"/> <item android:drawable="@drawable/pressed_item" android:state_pressed="true"/> <item android:drawable="@android:color/transparent"/> </selector>
And stretchable:
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="#FF0000"/> </shape>
What is worng? Somebody?
source share