我正在尝试更改ActionBar中标题文字的颜色,但我似乎无法让它工作
这是我尝试使用的风格
<style name="TitleColorStyle" parent="android:TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/white</item>
</style>
在我的应用主题中,我使用titleTextStyle
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowContentOverlay">@null</item>
<item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
<item name="android:actionDropDownStyle">@android:style/Widget.Holo.Spinner</item>
<item name="android:titleTextStyle">@style/TitleColorStyle</item>
</style>
我没有使用正确的样式来改变颜色吗?
答案 0 :(得分:2)
您需要为actionBarStyle
设置自定义样式,然后像这样更改titleTextStyle
<style name="ThemeHoloLight" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="android:Widget.Holo.Light.ActionBar">
<item name="android:titleTextStyle">@style/HoloTitleText</item>
</style>
<style name="HoloTitleText" parent="android:TextAppearance.Holo">
<item name="android:textColor">@android:color/white</item>
</style>
答案 1 :(得分:0)
Blackbelt是对的 - 您的父母不符合正确的语法。试试这个:
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
答案 2 :(得分:0)
<强>的AndroidManifest.xml:强>
<application android:theme="@style/MyAppTheme"
<强>值/ styles.xml:强>
<style name="MyAppTheme" parent="android:Theme.Light">
<!-- Customize your theme here. -->
</style>
<强>值-V11 / styles.xml:强>
<style name="MyAppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<!-- Customize your theme here. -->
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@color/orangeDark</item>
<item name="android:titleTextStyle">@style/MyActionBar.Text</item>
</style>
<style name="MyActionBar.Text" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
<item name="android:textStyle">bold</item>
</style>
答案 3 :(得分:0)
此代码可以使用
styles.xml
<style name="AppTheme" parent="@android:Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBar</item>
<item name="android:actionBarWidgetTheme">@style/ActionBar</item>
<item name="android:actionMenuTextAppearance">@style/ActionMenu</item>
<item name="android:itemTextAppearance">@style/ActionMenu</item>
</style>
<style name="ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@color/blue</item>
<item name="android:textColorHint">@android:color/widget_edittext_dark</item>
<item name="android:titleTextStyle">@style/ActionBarTitleText</item>
</style>
<style name="ActionMenu" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Menu">
<item name="android:textColor">@drawable/selector_action_bar_menu</item>
<item name="android:textSize">@dimen/text_label</item>
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">false</item>
</style>
<style name="ActionBarTitleText" parent="@android:style/TextAppearance.Holo">
<item name="android:textSize">@dimen/text_action_bar_title</item>
<item name="android:textColor">@android:color/white</item>
</style>
drawable / selector_action_bar_menu
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_enabled="false" android:color="@android:color/darker_gray"/>
<item android:state_enabled="true" android:color="@android:color/white"/>
</selector>
重写样式&#34; android:actionMenuTextAppearance&#34;和&#34; android:titleTextStyle&#34;。我用一个选择器来改变它。
我希望这会对你有所帮助。