Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionbar button background

I want to customize actionbar buttons with an image both for pressed and not pressed state. I put a drawable selector on android:icon with two states (pressed and not pressed). The problem is that, if I press the button, I still have the blue background (ics holo style) along with my pressed button icon. How can I remove this behaviour from actionbar customized icon buttons?

Thanks

like image 810
Matroska Avatar asked Feb 14 '12 22:02

Matroska


People also ask

How can change ActionBar background color in android programmatically?

To change background color of Action Bar in Kotlin Android, set the colorPrimary in themes. xml, with a required color. We can also dynamically change the background color of Action Bar programmatically by setting background drawable for support action bar with the required color drawable.

How do I change the color of my status bar?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar. Step 3: In your MainActivity, add this code in your onCreate method.


2 Answers

I think the more specific way is to put this attribute in your application Theme:

    <item name="android:actionBarItemBackground">@android:color/transparent</item>

Also put this if you're using ActionBarSherlock:

    <item name="actionBarItemBackground">@android:color/transparent</item>
like image 127
Randy Sugianto 'Yuku' Avatar answered Oct 17 '22 08:10

Randy Sugianto 'Yuku'


I have fixed the problem putting

 <item name="android:selectableItemBackground">@color/transparent</item>

in styles.xml. I thought it would have affected all the select styles but it seems it affects just the actionbar.

like image 34
Matroska Avatar answered Oct 17 '22 09:10

Matroska