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?
Asked
Active
Viewed 1.6k times
5 Answers
5
In your onCreate-method add the following:
setTitleColor(YOUR PREFERED COLOR);

Bevor
- 8,396
- 15
- 77
- 141
-
2Yeah, does not work with Action Bar on Android 4.0+. In that case, [check out this answer](http://stackoverflow.com/questions/9920277/how-to-change-action-bar-title-color-in-code/10592561#10592561). – Jonik Jan 14 '14 at 10:51
1
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));

Sergey Shustikov
- 15,377
- 12
- 67
- 119

TanvirChowdhury
- 2,498
- 23
- 28
1
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

Community
- 1
- 1

strongmayer
- 488
- 1
- 5
- 14
0
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

Bhaumik Sathvara
- 129
- 1
- 5
0
use this one
setTitleColor(Color.BLUE);
you can choose different color from Color class.

Chirag
- 2,321
- 24
- 36