When I made projects using Android Studio before, the activity action bar title was white by default. I created a new project with same settings as the previous projects (API level 11), but the default color of the activity title color is black. I didn't change anything at all, this is a fresh project. I tried using styles but nothing is working.
Asked
Active
Viewed 1,817 times
3 Answers
1
The action bar title color for a new project depends on the default theme used.In case of dark action bar the title color is white,please go and check the theme used in manifest.

Anshul
- 79
- 4
-
It uses the default theme, which is this. `
-
try replacing "Theme.AppCompat.Light" by "Theme.AppCompat.Light.DarkActionBar" when your action bar theme is dark the title automatically gets light & for adding any code on here just give four spaces before the line it will get formatted – Anshul Sep 09 '17 at 19:09
0
in order to change the color of actionbar title you can you can use this code in your class :
actionBar.setTitle(Html.fromHtml("<font color='#ffffff'>ActionBarTitle </font>"));
// to choose white
or change your actionbar style in res/values/styles.xml
file:
<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>
keep in mind you should change the style you chose before in manifest.xml for your app

mohammadreza khalifeh
- 1,510
- 2
- 18
- 32
-
Where is `MyTheme` found? Should it already be there? I'm getting errors on it. – Cs_Is_Better Sep 09 '17 at 19:06
0
If you want to change it programmatically below is the code.
The ActionBar ID is not available directly, so you have to do little bit of hacking here.
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);
}
}

Zafar Kurbonov
- 2,077
- 4
- 19
- 42