修改ActionBar中Android项目的样式
如何修改 Android 应用程序操作栏上项目的样式?
我尝试了以下操作:
<item name="android:actionBarStyle">@style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="@style/ActionBar">
<item name="android:background">@color/black</item>
<item name="android:actionMenuTextColor">#FF00FF</item>
</style>
我可以修改操作栏的背景,但不能修改操作栏中项目的文本颜色。我该怎么做呢?
编辑:
我尝试了几乎所有找到的 android:action
属性,但除了背景之外我无法更改任何内容。只有以下代码的第一个
对我的代码进行了更改。无论我在测试样式上设置哪个值,它都不会改变任何东西。为什么会发生这种情况?
<item name="android:actionBarStyle">@style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="@style/ActionBar">
<item name="android:background">#FF0000</item>
<item name="android:actionMenuTextColor">@style/Test</item>
<item name="android:actionButtonStyle">@style/Test</item>
<item name="android:actionModeBackground">@style/Test</item>
<item name="android:actionMenuTextAppearance">@style/Test</item>
</style>
<style name="Test">
<item name="android:textColor">@color/white</item>
<item name="android:background">#FF0000</item>
</style>
How can I modify the style of the items on the Action bar of an Android Application?
I tryed the following:
<item name="android:actionBarStyle">@style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="@style/ActionBar">
<item name="android:background">@color/black</item>
<item name="android:actionMenuTextColor">#FF00FF</item>
</style>
The background of the Action bar I was able to modify, but not the text Colors of the items in the Action bar. How can I do it?
EDIT:
I tried pretty much all the android:action
attributes I found, but I couldn't manage to change anything other than the background. Only the first <item name="android:background">#FF0000</item>
of the following code makes changes on my code. No matter which values I put on the Test style, it doesn't change anything. Why is it happening?
<item name="android:actionBarStyle">@style/ActionBar.Light</item>
<style name="ActionBar.Light" parent="@style/ActionBar">
<item name="android:background">#FF0000</item>
<item name="android:actionMenuTextColor">@style/Test</item>
<item name="android:actionButtonStyle">@style/Test</item>
<item name="android:actionModeBackground">@style/Test</item>
<item name="android:actionMenuTextAppearance">@style/Test</item>
</style>
<style name="Test">
<item name="android:textColor">@color/white</item>
<item name="android:background">#FF0000</item>
</style>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想更改操作栏中菜单项的颜色,您必须在主题样式中设置 actionMenuTextColor。
您没有在 actionMenuTextAppearance 中定义菜单项颜色!
If you want to change the color of the menu items in the action bar you have to set the actionMenuTextColor in your theme style.
You don't define the menu item colors in the actionMenuTextAppearance!
您可以通过以下方式更改颜色:-
You can change the color by:-