Android的动作栏:更改操作按钮的颜色按钮、颜色、动作、操作

2023-09-13 23:39:14 作者:Theprisoners(囚徒)

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

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.