Android – How to change action bar title color in code


I'm having trouble changing androids action bar title color programmatically for v11 and up. I can get it done in xml but need to change it dynamically in code. How should I go about this? Thanks in advance.

Best Solution

The ActionBar title ID is hidden, or in other words, it's internal and accessing it can't be done typically. You can reference it using Resources.getIdentifier then View.findViewById though.

Grab the ID for the action_bar_title

int titleId = getResources().getIdentifier("action_bar_title", "id", "android");

Now you can use the ID with a TextView

TextView abTitle = (TextView) findViewById(titleId);