Remove actionbar item blue background

て烟熏妆下的殇ゞ 提交于 2019-12-21 12:36:22

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/9923364/remove-actionbar-item-blue-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!