操作栏背景隐藏标题android
action bar background hides the title android
在我更改操作栏的颜色后,标题消失了
我所看到的只是一个没有文字的橙色背景的操作栏。如果我删除 "actionBarStyle" 属性,文本就会出现。
我想要做的就是为我的标题文本和向上按钮设置白色。
我的 style.xml:
<style name="SprayTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/orange_background</item>
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:actionMenuTextColor">@color/background_material_light</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/material_blue_grey_800</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
您可以使用 span 来获得白色标题:
SpannableString title = new SpannableString("ExampleTitle");
title.setSpan(new ForegroundColorSpan(android.R.color.white), 0, title.getLength());
然后:
getActionBar().setTitle(title);
就这样吧...您可以将操作栏标题的颜色更改为...只需将行放入 oncreate() 方法
getSupportActionBar().setTitle(Html.fromHtml("<Strong><font color='#FF0000'>Action </font></Strong>"+"<font color='#ffffff'>Bar</font>" +"<font color='#ffffff'>Title </font>"));
我为操作栏标题取了 3 种不同的颜色.....
试一试
这是非常基本的解决方案:
将您的父样式更改为
<style name="SprayTheme" parent="Theme.AppCompat.Light.DarkActionBar">
如果您只想要白色文本颜色,则无需提供额外的文本样式。
在我更改操作栏的颜色后,标题消失了 我所看到的只是一个没有文字的橙色背景的操作栏。如果我删除 "actionBarStyle" 属性,文本就会出现。 我想要做的就是为我的标题文本和向上按钮设置白色。 我的 style.xml:
<style name="SprayTheme" parent="Theme.AppCompat.Light">
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/orange_background</item>
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<item name="android:actionMenuTextColor">@color/background_material_light</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/material_blue_grey_800</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
您可以使用 span 来获得白色标题:
SpannableString title = new SpannableString("ExampleTitle");
title.setSpan(new ForegroundColorSpan(android.R.color.white), 0, title.getLength());
然后:
getActionBar().setTitle(title);
就这样吧...您可以将操作栏标题的颜色更改为...只需将行放入 oncreate() 方法
getSupportActionBar().setTitle(Html.fromHtml("<Strong><font color='#FF0000'>Action </font></Strong>"+"<font color='#ffffff'>Bar</font>" +"<font color='#ffffff'>Title </font>"));
我为操作栏标题取了 3 种不同的颜色..... 试一试
这是非常基本的解决方案: 将您的父样式更改为
<style name="SprayTheme" parent="Theme.AppCompat.Light.DarkActionBar">
如果您只想要白色文本颜色,则无需提供额外的文本样式。