如何更改使用XML的ActionBarActivity的动作条的背景颜色?如何更改、颜色、背景、动作

2023-09-11 10:43:26 作者:折月煮酒

详细信息:

我伸出ActionBarActivity。 Eclipse和SDK完全修补为2011-11-06。

I'm extending ActionBarActivity. Eclipse and SDK fully patched as of 2011-11-06.

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14" />  

部署到三星设备与Android 2.3.3 应用具有安卓主题=@安卓风格/ Theme.Light

Deployed to Samsung device with Android 2.3.3 Application has android:theme="@android:style/Theme.Light"

问题:申请很轻,但动作条是蓝色与灰色的图标,对蓝色背景难以看清。我也想在ActionBar要轻,所以他们灰色的图标更加明显。

Issue: application is light, but ActionBar is blue with grey icons, hardly visible against the blue background color. I also want the ActionBar to be light, so they grey icons are more visible.

我已经试过修改样式,但都无济于事。 我可能失去了一些东西微不足道。

I've tried modifying the styles but to no avail. I'm probably missing something trivial.

如何使用我改变ActionBarActivity的动作条的背景色XML?

推荐答案

根据文档 - 你可以控制的行为,并与动作条API,它们分别加入的Andr​​oid 3.0(API级别11)的操作栏的可见性

As per documentation - "You can control the behaviors and visibility of the action bar with the ActionBar APIs, which were added in Android 3.0 (API level 11)."

所以,动作条会不会为你的目标环境,这是API 10级(安卓2.3.3)的工作。

So, ActionBar will not work for your target environment which is at API level 10 (Android 2.3.3).

以防万一,如果你的目标的最低API级别11,您可以通过定义自定义样式,为改变ActionBar的背景色:

Just in case, if you target for minimum API level 11 , you can change ActionBar's background color by defining custom style, as:

<resources>
    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
    </style>

    <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">ANY_HEX_COLOR_CODE</item>
    </style>
</resources>

和,设置的MyTheme为主题的应用程序/活动。

And, set "MyTheme" as theme for application / activity.

希望这有助于...