Android 应用标签颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20597224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android app label color
提问by user3082220
I don't want to create any custom layout for app label, just want to change it's color to white (now it's black). How could I do that?
我不想为应用程序标签创建任何自定义布局,只想将其颜色更改为白色(现在是黑色)。我怎么能那样做?
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/bg_blue_solid_onclick</item>
//////CHANGE label color
</style>
</resources>
回答by Raghunandan
styles.xml
样式文件
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF9D21</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
</style>
colors.xml
颜色文件
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
For more info
欲了解更多信息
https://developer.android.com/training/basics/actionbar/styling.html#CustomText
https://developer.android.com/training/basics/actionbar/styling.html#CustomText
Snap
折断
Edit : For making it bold
编辑:为了使其大胆
<style name="MyActionBarTitleText"
parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
<item name="android:textStyle">bold</item>
</style>
回答by fllo
You need to style the android:titleTextStyle
in your ActionBar.
您需要android:titleTextStyle
在 ActionBar 中设置样式。
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/MyTextTitle</item>
</style>
<style name="MyTextTitle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
You can see this in Android Documentation: Customize the Text Color in ActionBar
您可以在 Android 文档中看到这一点:自定义 ActionBar 中的文本颜色
Hope this helps.
希望这可以帮助。
回答by Francisco Sales
None of the previous answers worked for me, so I'm showing the one that worked in my case.
以前的答案都不适合我,所以我展示了对我有用的答案。
<style name="AppThemeCustom" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@android:color/black</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="android:windowBackground">@android:color/white</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/MyTitleTextStyle</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">@style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@android:color/black</item>
</style>
I wish if you find yourself in my situation this solution save your day. LOL
我希望如果您发现自己处于我的情况,这个解决方案可以节省您的时间。哈哈
回答by Shahab Ghannadzadeh
in styles.xml
在styles.xml中
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
in toolbar
在工具栏中
android:theme="@style/AppTheme.AppBarOverlay"