Home
> Tricks & Tips > Colorizing the Title Bar
Colorizing the Title Bar
It’s very interesting if we can do some customizing over title bar on screen, like this:
Here the tricks:
package pete.android.study;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewParent;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// load title bar from Android layout
TextView titleBar = (TextView)getWindow().findViewById(android.R.id.title);
if (titleBar != null) {
// set text color, YELLOW as sample
titleBar.setTextColor(Color.YELLOW);
// find parent view
ViewParent parent = titleBar.getParent();
if (parent != null && (parent instanceof View)) {
// set background on parent, BRICK as sample
View parentView = (View)parent;
parentView.setBackgroundColor(Color.rgb(0x88, 0x33, 0x33));
}
}
}
}
If you want to do some customization on default Android screen layout by re-construct the framework, then refer to this file: platforms/android-2.3.3/data/res/layout/screen.xml, whereas replace 2.3.3 by your version.
Have fun
Cheers,
Pete Houston
Categories: Tricks & Tips
Tags: bar, color, customize, title
Leave a Reply Cancel reply
Calendar
Categories
- Home (4)
- Learning (149)
- Books & Materials (2)
- Design Patterns (2)
- PhoneGap (1)
- Tricks & Tips (75)
- Tutorials (69)
- Of Diary (19)
- Pete's Works (8)
- Applications (7)
- Publications (1)
- Tools (7)
Recent Posts
Most Popular
Tag Cloud
activity
android
application
applications
bitmap
blog
cache
color
custom
data
database
design
detect
device
diary
effect
element
emulator
file
filter
home
houston
image
intent
launcher
memory
mp3
new
parse
pete
processing
query
screen
secret
showcase
sqlite
tag
tips
tools
tricks
tutorials
view
xml
xpath
zip
Archives
- January 2013 (5)
- December 2012 (4)
- October 2012 (2)
- September 2012 (1)
- August 2012 (2)
- July 2012 (12)
- June 2012 (1)
- May 2012 (7)
- March 2012 (1)
- February 2012 (3)
- January 2012 (2)
- December 2011 (8)
- November 2011 (12)
- October 2011 (19)
- September 2011 (16)
- July 2011 (29)
- June 2011 (63)
Statistics
- 547,062 View

I tried using setText() although there is no error title doesn’t change its the same as set in manifest. Then I removed the title for activity from manifest then the title of the app is being used as the title but the setText() content is totally ignored, although there are no errors or exceptions.
How to change the title of the title bar