我正在努力实现两件事
这一切都在XML上。
实验结束后有什么用?
菜单项的文字颜色在任何地方都无效。在示例代码中,当我在主Theme标签中声明MenuTextStyle时,我能够更改文本大小而不是颜色。
<style name="Theme.SexyApp" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">@style/Widget.SexyApp.ActionBar</item>
<item name="android:actionBarStyle">@style/Widget.SexyApp.ActionBar</item>
<item name="android:actionBarItemBackground">@drawable/list_state</item>
<item name="actionBarItemBackground">@drawable/list_state</item>
<item name="android:actionMenuTextAppearance">@style/Theme.SexyApp.ActionBar.MenuTextStyle</item>
<item name="actionMenuTextAppearance">@style/Theme.SexyApp.ActionBar.MenuTextStyle</item>
</style>
<style name="Widget.SexyApp.ActionBar" parent="@style/Widget.Sherlock.Light.ActionBar">
<item name="android:displayOptions">showHome|useLogo|showTitle</item>
<item name="android:titleTextStyle">@style/Theme.SexyApp.ActionBar.TextAppearance</item>
<item name="titleTextStyle">@style/Theme.SexyApp.ActionBar.TextAppearance</item>
</style>
<style name="Theme.SexyApp.ActionBar.TextAppearance" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20dp</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowColor">#333333</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDy">1</item>
</style>
<style name="Theme.SexyApp.ActionBar.MenuTextStyle" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">13dp</item>
<item name="android:textStyle">bold</item>
<item name="android:shadowColor">#333333</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDy">1</item>
</style>
答案 0 :(得分:12)
要更改菜单项文本颜色,您需要将actionMenuTextColor项添加到主题样式中,如下面的代码所示:
<style name="ThemeName" parent="@style/Theme.Sherlock.Light">
<item name="actionMenuTextColor">@color/white</item>
<item name="android:actionMenuTextColor">@color/white</item>
</style>
答案 1 :(得分:1)
要更新菜单项文本外观(颜色,大小,样式),您需要在两个不同的位置进行更改。以下答案适用于sherlock.actionbar
1:在themes.xml文件中添加以下行:
<style name="Theme.Mytheme" parent="@style/Theme.Sherlock">
<item name="android:actionMenuTextAppearance">@style/CustomMenuItem</item> // define custom style in the style.xml file.
<item name="actionMenuTextColor">@color/mycolor</item>
<item name="android:actionMenuTextColor">@color/mycolor</item>
2:在你的styles.xml中
<style name="CustomMenuItem" parent="@style/TextAppearance.Sherlock.Widget.ActionBar.Menu">
<item name="android:textStyle">normal</item>
<item name="android:textSize">15sp</item>
<item name="android:textAllCaps">false</item>
</style>