Android的动作栏:更改操作按钮的颜色 [英] Android Action Bar: Changing the color of Action Buttons

查看:294
本文介绍了Android的动作栏:更改操作按钮的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个操作栏,看起来像这样的应用程序:

I have an app with an action bar that looks like this:

我想的菜单操作按钮家和注销的文字是白色为好。我怎样才能改变他们的文本颜色?

I would like the text of the menu action buttons "Home" and "Logout" to be white as well. How can I change their text color?

让我知道如果你想看到任何code。

Let me know if you want to see any code.

谢谢!

推荐答案

由于我认为它这是一个名为的android简单的属性:actionMenuTextColor

As i perceive it this is a simple attribute called android:actionMenuTextColor.

要正确使用它,你应该创建自己的风格,像这样的:

To use it properly you should create your own styles, like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="myTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionMenuTextColor">@color/actionBarText</item>
    </style>

    <style name="myTheme.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
    </style>

    <style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
        <item name="android:textColor">@color/actionBarText</item>
    </style>

</resources>

然后设置@色/ actionBarText到您所选择的颜色。你也可以在这里定义其它的值例如像背景颜色。

And then set @color/actionBarText to the color of your choice. You can also define other values here like for instance background color.

这篇关于Android的动作栏:更改操作按钮的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆