繁体   English   中英

更改操作栏的标题文本颜色

[英]change title text color of action bar

我使用了Android操作栏样式生成器来生成我的操作栏,但是我想更改操作栏标题的颜色

这是生成器的代码给我:style.xml

<resources>

<style name="Theme.Example" parent="@style/Theme.AppCompat.Light">
    <item name="actionBarItemBackground">@drawable/selectable_background_example</item>
    <item name="popupMenuStyle">@style/PopupMenu.Example</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Example</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.Example</item>
    <item name="actionDropDownStyle">@style/DropDownNav.Example</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.Example</item>
    <item name="actionModeBackground">@drawable/cab_background_top_example</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_example</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Example</item>


</style>

<style name="ActionBar.Solid.Example" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
    <item name="background">@drawable/ab_solid_example</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_example</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_example</item>
    <item name="progressBarStyle">@style/ProgressBar.Example</item>
</style>

<style name="ActionBar.Transparent.Example" parent="@style/Widget.AppCompat.Light.ActionBar">
    <item name="background">@drawable/ab_transparent_example</item>
    <item name="progressBarStyle">@style/ProgressBar.Example</item>
</style>

<style name="PopupMenu.Example" parent="@style/Widget.AppCompat.Light.PopupMenu">   
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>   
</style>

<style name="DropDownListView.Example" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_example</item>
</style>

<style name="ActionBarTabStyle.Example" parent="@style/Widget.AppCompat.Light.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_example</item>
</style>

<style name="DropDownNav.Example" parent="@style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
    <item name="android:background">@drawable/spinner_background_ab_example</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_example</item>
</style>

<style name="ProgressBar.Example" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_example</item>
</style>

<style name="ActionButton.CloseMode.Example" parent="@style/Widget.AppCompat.Light.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_example</item>
</style>

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

然后我添加了此代码。

<item name="actionBarStyle">@style/myTheme.ActionBar</item>

<style name="myTheme.ActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="titleTextStyle">@style/myTheme.ActionBar.Text</item>
</style>

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

但是它不起作用,有人可以帮助我吗?

尝试为actionBar样式设置自定义样式,然后更改文本样式

<style name="myTheme.ActionBar" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="android:actionBarStyle">@style/myTheme.ActionBar.Text</item>
</style>

<style name="myTheme.ActionBar.Text" parent="@style/Widget.AppCompat.ActionBar.Solid">
    <item name="android:titleTextStyle">@style/actionBarText</item>
</style>

<style name="actionBarText" parent="@android:style/TextAppearance">
    <item name="android:textColor">@android:color/white</item>
</style>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM