Cam*_*boy 1 android android-actionbar android-actionbar-compat
我想在我的应用程序中更改ActionBar的标题文本颜色.我在很多方面都尝试过,但我无法实现.我不想以编程方式执行此操作,因为当应用程序启动时,它会显示具有先前颜色的操作栏,然后更改为新的操作栏.我支持Api Level 8,我的xml是使用Android Action Bar Style Generator生成的.然后我尝试用此更改标题文本颜色.标题文字颜色仍为黑色.
这是我的代码:
<resources>
<style name="Theme.Dbtools_style" parent="@style/Theme.AppCompat.Light">
<item name="actionBarItemBackground">@drawable/selectable_background_dbtools_style</item>
<item name="popupMenuStyle">@style/PopupMenu.Dbtools_style</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Dbtools_style</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Dbtools_style</item>
<item name="actionDropDownStyle">@style/DropDownNav.Dbtools_style</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Dbtools_style</item>
<item name="actionModeBackground">@drawable/cab_background_top_dbtools_style</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_dbtools_style</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Dbtools_style</item>
<!-- Remove icon in Action Bar -->
<item name="android:displayOptions">showHome|homeAsUp|showTitle</item>
<item name="displayOptions">showHome|homeAsUp|showTitle</item>
<item name="android:icon">@android:color/transparent</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/ActionBar.Solid.Dbtools_style</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<item name="background">@drawable/ab_solid_dbtools_style</item>
<item name="backgroundStacked">@drawable/ab_stacked_solid_dbtools_style</item>
<item name="backgroundSplit">@drawable/ab_bottom_solid_dbtools_style</item>
<item name="progressBarStyle">@style/ProgressBar.Dbtools_style</item>
<!-- Title Text Color -->
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<style name="ActionBar.Transparent.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="background">@drawable/ab_transparent_dbtools_style</item>
<item name="progressBarStyle">@style/ProgressBar.Dbtools_style</item>
</style>
<style name="PopupMenu.Dbtools_style" parent="@style/Widget.AppCompat.Light.PopupMenu">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_dbtools_style</item>
</style>
<style name="DropDownListView.Dbtools_style" parent="@style/Widget.AppCompat.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_dbtools_style</item>
</style>
<style name="ActionBarTabStyle.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_dbtools_style</item>
</style>
<style name="DropDownNav.Dbtools_style" parent="@style/Widget.AppCompat.Light.Spinner.DropDown.ActionBar">
<item name="android:background">@drawable/spinner_background_ab_dbtools_style</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_dbtools_style</item>
<item name="android:dropDownSelector">@drawable/selectable_background_dbtools_style</item>
</style>
<style name="ProgressBar.Dbtools_style" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_dbtools_style</item>
</style>
<style name="ActionButton.CloseMode.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_dbtools_style</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Dbtools_style.Widget" parent="@style/Theme.AppCompat">
<item name="popupMenuStyle">@style/PopupMenu.Dbtools_style</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Dbtools_style</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
我解决了我的问题.问题是我在一个api级别为14+的设备上测试,我只是将样式添加到res/values.我不得不在res/values-v14中添加样式.我附上我的代码:
RES /值/ styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Dbtools_style" parent="@style/Theme.AppCompat.Light">
<!-- Title Text Color -->
<item name="actionMenuTextColor">@color/white</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<!-- Title Text Color -->
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
RES /值-V14/styles.xml
<style name="Theme.Dbtools_style" parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/ActionBar.Solid.Dbtools_style</item>
<!-- Title Text Color -->
<item name="android:actionMenuTextColor">@color/white</item>
</style>
<style name="ActionBar.Solid.Dbtools_style" parent="@style/Widget.AppCompat.Light.ActionBar.Solid">
<!-- Title Text color -->
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8791 次 |
| 最近记录: |