Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove actionbar item blue background

I am creating an actionbar with custom looking buttons that I put in the icon section of menu.xml.

The problem is that, when I press them, I see both the selected version of the image of the button and the blue background of the holo theme.

This is my menu.xml:

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

    <item
        android:id="@+id/current_position"
        android:icon="@drawable/ab_location_layer"
        android:menuCategory="container"
        android:showAsAction="ifRoom"
        android:title="Current position">
    </item>

</menu>

The ab_location_layer is this:

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

    <item android:drawable="@drawable/ab_location_pressed" android:state_pressed="true"/>
    <item android:drawable="@drawable/ab_location" android:state_pressed="false"/>

</selector>

The ab_location_layer contains an image that is smaller than the actionBar. How is possible to remove the blue background on actionbar? I am also using actionbarsherlock.

Thanks

like image 992
Matroska Avatar asked Mar 29 '12 10:03

Matroska


People also ask

How do I get rid of blue on Android?

The majority of the Android devices feature a built-in blue light setting, one which you can enable by going to Settings and tap on Display. There you will find a setting named either Night Light or Blue Light, through which you can adjust the colouring temperature and schedule when you want to turn it on and off.

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 remove the action bar?

If you want to hide Action Bar from the entire application (from all Activities and fragments), then you can use this method. Just go to res -> values -> styles. xml and change the base application to “Theme. AppCompat.


1 Answers

I found the answer on ActionBarSherlock Mailing List:

you have to put this

  <item name="android:selectableItemBackground">@null</item>
    <item name="android:actionBarItemBackground">@null</item>
    <item name="actionBarItemBackground">@null</item>

to your theme and not in ActionBar theme

like image 82
Matroska Avatar answered Oct 13 '22 14:10

Matroska