安卓:标题栏颜色不会改变 [英] Android: Title Bar Color don't change

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

问题描述

我想改变我的应用程序标题栏的颜色,并尝试了这种方式:

I wanna change my Apps Titlebar color and tried it in this way:

清单文件的部分:

<application
        android:icon="@drawable/icon"
        android:label="@string/app_name"  
        android:theme="@style/Theme.MyTitleBar" ></application>

文件styles.xml的风格块的部分:

The style block part of the file styles.xml:

 <style name="Theme.MyTitleBar" parent="android:Theme">
        <item name="android:colorBackground">#FFFFFF</item>
        <item name="android:background">#FFFFFF</item>
        <item name="android:textColor">@android:color/black</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">16sp</item>
 </style>

但是,只有文本颜色和属性的改变是正确的。任何客人我做错了什么?

But only the text color and attributes changes correct. Any guest what I did wrong?

推荐答案

编辑:我加了一部分的动作条(抱歉,我只放了对话框在第一次)

I added the part for the ActionBar (sorry I put only for Dialogs at first)

您可以按照这一点,它可以让你改变而且其它属性,只是标题栏:

You can follow this, it will allow you to change moreover other attributes that just the title bar:

只需调用清单文件中自定义主题:

Just call your custom theme in the manifest file:

 <application
    android:icon="@drawable/icon"
    android:label="@string/app_name"  
    android:theme="@style/AppTheme" >

然后在你的 styles.xml 创建这两个风格。第一个定义了这个主题,第二个,的样式之一应用的主题:

Then create these 2 styles in your styles.xml. The first one defines the theme, the second one, one of the styles to apply on the theme:

<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>

<style name="ActionBarStyle" parent="android:style/Widget.Holo.Light.ActionBar">     
    <item name="android:colorBackground">#FFFFFF</item>
    <item name="android:background">#FFFFFF</item>
    <item name="android:textColor">@android:color/black</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textSize">16sp</item>
</style>

注意:在这个例子中,我自定义主题全息光,你可以用这个看到:安卓风格/ Widget.Holo.Light.ActionBar

NOTE: In this example, I customize the theme Holo Light as you can see with this: android:style/Widget.Holo.Light.ActionBar.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆