Android: Title Bar Color don#39;t change(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:标题栏颜色不变


- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01