本文介绍了更改颜色标题栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改标题栏的颜色.我试过了:

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"

这篇关于更改颜色标题栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 23:37
查看更多