I have an ActionBar , the color of which matches the color of the pressed home button, and clicking imperceptibly!

How to change the color of the Actionbar button?

  • 2
    c API 14 you can change <item name="android:actionBarItemBackground">@drawable/btn</item> <item name="actionBarItemBackground">@drawable/btn</item> - tim_taller
  • @monomi tried, but wondered <14 - katso
  • one
    @katso then suppose that this can be done only by custom ActionBar - tim_taller

2 answers 2

Write an xml file with the selector tag:

 <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/button_pressed" android:state_pressed="true" /> <item android:drawable="@drawable/button" /> </selector> 

moreover, in android:drawable="" you can shove both a picture and a color.

and the selector file must be in the \project_name\res\drawable .

then refer to this selector either in code or in the layout description.

  • The question is how to apply this selector to the action buttons - katso

Selectors drawables .

You can also override the android:actionBarItemBackground in the used theme.

  • It is clear how to apply it to the action buttons? - katso