问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/23989310/change-the-text-color-of-the-activity-title