我无法改变机器人的操作栏标题颜色编程为V11以上。我可以把它在XML完成,但需要动态地改变它在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.
在动作条
标题ID被隐藏,或者换句话说,它的内部和访问它不能被典型的做法。您可以使用它引用 Resources.getIdentifier
然后 View.findViewById
虽然。
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.
抢ID为action_bar_title
int titleId = getResources().getIdentifier("action_bar_title", "id", "android");
现在,您可以用ID与的TextView
Now you can use the ID with a TextView
TextView abTitle = (TextView) findViewById(titleId);
abTitle.setTextColor(colorId);