android – ActionBar menuitem按下背景颜色

android – ActionBar menuitem按下背景颜色,第1张

概述我用ActionBarSherlock创建了一个 *** 作栏.我想设置 *** 作栏的样式,这样当我按下menuitem(从溢出中d出的下拉项目)时,menuitem背景应该会改变颜色. (现在它改为默认的全息蓝色,我希望它是另一种颜色). 经过长时间的googleing和测试,我想到了这个: 的themes.xml: <style name="AppTheme" parent="Holo.Theme"> 我用ActionbarSherlock创建了一个 *** 作栏.我想设置 *** 作栏的样式,这样当我按下menuitem(从溢出中d出的下拉项目)时,menuitem背景应该会改变颜色. (现在它改为默认的全息蓝色,我希望它是另一种颜色).

经过长时间的Googleing和测试,我想到了这个:

的themes.xml:

<style name="Apptheme" parent="Holo.theme">    <item name="androID:popupMenuStyle">@style/PopupMenuStyle</item>    <item name="popupMenuStyle">@style/PopupMenuStyle</item></style><style name="PopupMenuStyle" parent="@style/Widget.Sherlock.PopupMenu">    <item name="androID:dropDownSelector">@drawable/menu_selector</item></style>

menu_selector.xml :(如abs__List_selector_holo_dark.xml)

<?xml version="1.0" enCoding="utf-8"?><selector xmlns:androID="http://schemas.androID.com/apk/res/androID">    <item androID:state_window_focused="false" androID:drawable="@androID:color/transparent" />    <item androID:state_focused="true"  androID:state_enabled="false" androID:state_pressed="true" androID:drawable="@drawable/abs__List_selector_Disabled_holo_dark" />    <item androID:state_focused="true"  androID:state_enabled="false"                              androID:drawable="@drawable/abs__List_selector_Disabled_holo_dark" />    <item androID:state_focused="true"                                androID:state_pressed="true" androID:drawable="@color/AppRed" />    <item androID:state_focused="false"                               androID:state_pressed="true" androID:drawable="@color/AppRed" />    <item androID:state_focused="true"                                                             androID:drawable="@drawable/abs__List_focused_holo" />    <item                                                              androID:drawable="@color/AppRed" /></selector>

不幸的是,背景仍然变为蓝色而不是红色.
我在这里失踪了什么?

解决方法 这将为您生成Actionbar样式,您可以选择仅更改强调颜色,这将修改 *** 作栏项目选择器(您仍然必须将它生成的所有文件复制到您的项目中):

http://jgilfelt.github.io/android-actionbarstylegenerator/

总结

以上是内存溢出为你收集整理的android – ActionBar menuitem按下背景颜色全部内容,希望文章能够帮你解决android – ActionBar menuitem按下背景颜色所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1129272.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存