Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change title bar color in android activity? [duplicate]

Possible Duplicate:
Set title background color

How can I change the titlebar color in an Android app?

I tried:

this.setTitleColor(Color.BLUE); 

but it changes color of written text on it not title bar color.

like image 409
UMAR-MOBITSOLUTIONS Avatar asked Mar 05 '10 13:03

UMAR-MOBITSOLUTIONS


People also ask

How can I change the color of my title bar in Android?

Just go to res/values/styles.edit the xml file to change the color of action bar.

What is title bar in Android?

Android Title Bar or ActionBar or Toolbar is the header of any screen in an App.


1 Answers

getWindow() method of Context return the current view context, for get the title bar of an Activity, android.id.id.title

View title = getWindow().findViewById(android.R.id.title);
View titleBar = (View) title.getParent();
titleBar.setBackgroundColor(Color.RED);` 
like image 119
Ashish Dwivedi Avatar answered Oct 17 '22 19:10

Ashish Dwivedi