-1

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.

Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
user3548779
  • 321
  • 2
  • 8
  • 19
  • [http://stackoverflow.com/questions/9920277/how-to-change-action-bar-title-color-in-code](http://stackoverflow.com/questions/9920277/how-to-change-action-bar-title-color-in-code) – M D Jun 02 '14 at 07:30

1 Answers1

2

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

Community
  • 1
  • 1
Shayan Pourvatan
  • 11,898
  • 4
  • 42
  • 63