【问题标题】:Overriding the overflow menu style through XML通过 XML 覆盖溢出菜单样式
【发布时间】:2014-10-07 15:46:13
【问题描述】:
我正在尝试更改溢出菜单项的textColor。
到目前为止,我只找到了用反射和/或在 LayoutInflater 上设置工厂来检查视图名称是否为内部 menuItem 的代码解释,返回具有正确样式的 TextView。
当然,主题中应该有一种可以被覆盖的样式。有人知道怎么做吗?
【问题讨论】:
标签:
android
android-layout
android-xml
android-theme
android-styles
【解决方案1】:
浏览了很多StackOverflow问答和博文,终于找到了正确的样式来覆盖。
在您定义应用主题的 style.xml 或 theme.xml 中,包括:
<resources>
<style name="Theme.AppTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarWidgetTheme">@style/OverflowTextStyle</item>
</style>
</rescources>
您要覆盖的样式属性是android:actionBarWidgetTheme。在主题声明中包含该项目。 (我最初预计它会在 android:actionBarStyle 的定义中定义,但 不是 它所属的位置;它只是应用程序主题中的一个项目。)
现在我们要做的就是在某处声明OverflowTextStyle 样式:
<resources>
<style name="OverflowTextStyle">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">18sp</item>
</style>
</resources>