2

我正在尝试使用 android:textColor 在我的样式中将我的操作栏(sherlock)应用程序标题颜色从黑色更改为白色,但它似乎不起作用。

我在http://jgilfelt.github.io/android-actionbarstylegenerator上生成了这个动作栏,但我认为 textColor 代码应该可以正常工作。

这是我从网站上获得的代码。我该怎么做才能让它变成白色只是为了标题?

<!-- ActionBar from Generator -->
<style name="Theme.xotab" parent="@style/Theme.xot">
    <item name="actionBarItemBackground">@drawable/selectable_background_xotab</item>
    <item name="popupMenuStyle">@style/PopupMenu.xotab</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.xotab</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.xotab</item>
    <item name="actionDropDownStyle">@style/DropDownNav.xotab</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.xotab</item>
    <item name="actionModeBackground">@drawable/cab_background_top_xotab</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_xotab</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.xotab</item>
</style>

<style name="ActionBar.Solid.xotab" parent="@style/Widget.Sherlock.Light.ActionBar.Solid">
    <item name="background">@drawable/ab_solid_xotab</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_xotab</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_xotab</item>
    <item name="progressBarStyle">@style/ProgressBar.xotab</item>
</style>

<style name="ActionBar.Transparent.xotab" parent="@style/Widget.Sherlock.Light.ActionBar">
    <item name="background">@drawable/ab_transparent_xotab</item>
    <item name="progressBarStyle">@style/ProgressBar.xotab</item>
</style>

<style name="PopupMenu.xotab" parent="@style/Widget.Sherlock.Light.ListPopupWindow">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_xotab</item>
</style>

<style name="DropDownListView.xotab" parent="@style/Widget.Sherlock.Light.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_xotab</item>
</style>

<style name="ActionBarTabStyle.xotab" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_xotab</item>
</style>

<style name="DropDownNav.xotab" parent="@style/Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
    <item name="android:background">@drawable/spinner_background_ab_xotab</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_xotab</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_xotab</item>
</style>

<style name="ProgressBar.xotab" parent="@style/Widget.Sherlock.Light.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_xotab</item>
</style>

<style name="ActionButton.CloseMode.xotab" parent="@style/Widget.Sherlock.Light.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_xotab</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.xotab.Widget" parent="@style/Theme.Sherlock">
    <item name="popupMenuStyle">@style/PopupMenu.xotab</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.xotab</item>
</style>
4

1 回答 1

2

您可以通过代码在 onCreate 中以更简单的方式执行此操作:

int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView Tv = (TextView)findViewById(titleId);
Tv.setTextColor(colorID);
于 2013-09-02T23:03:12.113 回答