Android:标题栏颜色不变

Android: Title Bar Color don#39;t change(Android:标题栏颜色不变)

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

问题描述

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

清单文件的一部分:

文件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">粗体</item><item name="android:textSize">16sp</item></风格>

但只有文本颜色和属性更改正确.任何客人我做错了什么?

解决方案

我添加了 ActionBar 的部分(对不起,我一开始只放了 Dialogs)

你可以按照这个,它可以让你改变除了标题栏之外的其他属性:

只需在清单文件中调用您的自定义主题即可:

 <应用程序android:icon="@drawable/icon"android:label="@string/app_name"android:theme="@style/AppTheme" >

然后在您的 styles.xml 中创建这两种样式.第一个定义主题,第二个定义主题的样式之一:

<style name="AppTheme" parent="@android:style/Theme.Holo.Light"><item name="android:actionBarStyle">@style/ActionBarStyle</item></风格><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">粗体</item><item name="android:textSize">16sp</item></风格>

注意:在本例中,我自定义了 Holo Light 主题,如您所见:android:style/Widget.Holo.Light.ActionBar..p>

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

Part of the manifest file:

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

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?

解决方案

EDIT: 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" >

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>

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

这篇关于Android:标题栏颜色不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Android:标题栏颜色不变

基础教程推荐