android - 从在actionbarstylegenerator上创建的操作栏更改应用程序的标题颜色

标签 android android-layout actionbarsherlock android-actionbar

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

我在 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>

最佳答案

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

int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView Tv = (TextView)findViewById(titleId);
Tv.setTextColor(colorID);

关于android - 从在actionbarstylegenerator上创建的操作栏更改应用程序的标题颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18581816/

相关文章:

安卓工作室 : Project refresh failed. 。打开 zip 文件时出错

android - 如何使用android :onClick?

android - 用图标填充多边形

android - 删除文件夹后 mkdir() 返回 false

android - DialogPreference 的自定义属性

android - 某些样式在 TextView 中禁用 ImageSpan

android - 如何在 actionbarsherlock 中更改选项卡 'underbar' 的颜色

java - Android如何在 GridView 的每个元素上应用翻转旋转动画?

使用 SQLite 处理 Android 工具栏图标

android - 使用 SherlockActivity 在 SherlockFragments 中设置 setSupportProgressBarInminated