user3548779 user3548779 - 5 months ago 21
Android Question

Change the text color of the activity title

In Xamarin, how can I change the text colour of the text in the

ActionBar
?

I have changed the background colour successfully, but not the text colour.

Here is my code:

ColorDrawable colorDrawable = new ColorDrawable(Color.White);
ActionBar.SetBackgroundDrawable(colorDrawable);
this.TitleColor = Color.Black;


I cannot see a correct method in the
ActionBar
object, and specifying
this.TitleColor
does not work correctly.

Answer

did you try this?

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);
    }
}

more info on this Site

Comments