更改颜色标题栏
问题描述:
我想更改标题栏的颜色.我试过了:
I want to change the color of the title bar. I tried this:
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionBarStyle">@style/ColorBar</item>
</style>
<style name="ColorBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@color/white</item>
<item name="android:textColor">@color/orange</item>
</style>
但是它不起作用.上面显示的我的代码有什么问题?
But it doesn't work. What is wrong in my code shown above?
这是我要更改的文本的颜色,而不是背景的颜色(背景正在运行)
EDIT : it's the color of the text i want to change, not the background (it's running for the background)
答
这适用于所有设备,您需要支持库(appcompat_v7)
This should work for all devices, you will need the support library (appcompat_v7)
<style name="Theme" parent="@style/BaseTheme"></style>
<style name="BaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarStyle">@style/ActionBar</item>
<item name="android:actionBarStyle">@style/ActionBar</item>
</style>
<style name="ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">@color/orange </item>
<item name="background">@color/orange </item>
<item name="android:titleTextStyle">@style/ActionBar.Text</item>
<item name="titleTextStyle">@style/ActionBar.Text</item>
</style>
<style name="ActionBar.Text" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">@color/orange</item>
</style>
清单:
android:theme="@style/Theme"