我使用了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>
但这不起作用,任何人都可以帮助我吗?
答案 0 :(得分:0)
尝试为actionBar Style设置自定义样式,然后更改文本样式
<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>