操作栏按钮背景

发布于 2025-01-05 08:26:36 字数 151 浏览 5 评论 0原文

我想用图像自定义操作栏按钮,以表示按下和未按下状态。我在 android:icon 上放置了一个可绘制选择器,具有两种状态(按下和未按下)。问题是,如果我按下按钮,我仍然有蓝色背景(ics Holo 样式)以及按下的按钮图标。如何从操作栏自定义图标按钮中删除此行为?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瑾夏年华 2025-01-12 08:26:36

我认为更具体的方法是将此属性放在您的应用程序主题中:

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

如果您使用 ActionBarSherlock,也请放置此属性:

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

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>
回梦 2025-01-12 08:26:36

我已经解决了放入 styles.xml 的问题

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

。我认为它会影响所有选择的样式,但它似乎只影响操作栏。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文