How to change title bar color in android activity?

android, android-activity, layout

Solution

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);` 

Problem

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.

Original source

Related problems