Reputation: 21
In my app I populate title bar label from each activity but the text color in the activity and text color in title bar is same. How do I change the title bar text color to a different one?
Upvotes: 2
Views: 15844
Reputation: 129
ActionBar ab = getActionBar();
TextView tv = new TextView(getApplicationContext());
LayoutParams lp = new RelativeLayout.LayoutParams(
LayoutParams.MATCH_PARENT, // Width of TextView
LayoutParams.WRAP_CONTENT);
tv.setLayoutParams(lp);
tv.setTextColor(Color.RED);
ab.setCustomView(tv);
For more information check this link :
http://android--code.blogspot.in/2015/09/android-how-to-change-actionbar-title_21.html
Upvotes: 0
Reputation: 2445
you can do it from 2 places either in style.xml or proramatically
1.From style.xml : by Modifying TitleTextStyle -setting the android:textColour
value as desired
2.Or in code Programatically:
int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView yourTextView = (TextView)findViewById(titleId);
yourTextView.setTextColor(getResources().getColor(R.color.myColor));
Upvotes: 1
Reputation: 2321
use this one
setTitleColor(Color.BLUE);
you can choose different color from Color class.
Upvotes: 0
Reputation: 8605
In your onCreate-method add the following:
setTitleColor(YOUR PREFERED COLOR);
Upvotes: 5
Reputation: 488
You can implement a custom title bar (then you have to change the color of a simple TextView). Please check this: How to change the text on the action bar
Upvotes: 1