Change the text color of the activity title

为君一笑 提交于 2019-12-08 14:00:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!