之前我使用Android Studio制作项目时,活动操作栏标题默认为白色。 我创建了一个新项目,与之前的项目设置相同(API级别11),但活动标题颜色的默认颜色是黑色。我没有改变任何东西,这是一个全新的项目。 我尝试使用样式,但什么都不起作用。
之前我使用Android Studio制作项目时,活动操作栏标题默认为白色。 我创建了一个新项目,与之前的项目设置相同(API级别11),但活动标题颜色的默认颜色是黑色。我没有改变任何东西,这是一个全新的项目。 我尝试使用样式,但什么都不起作用。
为了改变actionbar标题的颜色,您可以在您的类中使用以下代码:
actionBar.setTitle(Html.fromHtml("<font color='#ffffff'>ActionBarTitle </font>"));
// to choose white
或者在res/values/styles.xml
文件中更改您的操作栏样式:
<resources>
<style name="MyCustomTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBarTheme</item>
</style>
<style name="MyActionBarTheme" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">ANY_HEX_COLOR_CODE</item>
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
</resources>
请记住,在您的应用程序的manifest.xml中,您应该更改之前选择的样式。
MyTheme
在哪里可以找到?它应该已经存在吗?我在使用时遇到了错误。 - Cs_Is_Better int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
if (actionBarTitleId > 0) {
TextView title = (TextView) findViewById(actionBarTitleId);
if (title != null) {
title.setTextColor(Color.RED);
}
}
</resources>` \n 对于代码混乱的问题我感到抱歉,不知道如何在这个网站上进行格式化。 - Cs_Is_Better