How I can change background color of titlebar without using theme. tnks in Android.
Asked
Active
Viewed 4,632 times
3 Answers
4
Try with the following code
View titleView = getWindow().findViewById(android.R.id.titlebar);
if (titleView != null) {
ViewParent parent = titleView.getParent();
if (parent != null && (parent instanceof View)) {
View parentView = (View)parent;
parentView.setBackgroundColor(Color.RED);
}
}

Sunil Kumar Sahoo
- 53,011
- 55
- 178
- 243
-
1@Friz14 Where did you find it? I ran into [a similar problem](http://stackoverflow.com/q/11263829/869501) and I can't find that `android.R.id.titlebar`. Thanks +1. – ateiob Jun 29 '12 at 14:54
-
I am using title instead of titlebar, and i am not able to change color of titlebar.. do i need to set anything else to make it work? – Vikas Gupta May 23 '13 at 05:24
0
ActionBar bar = getActionBar(); bar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.material_blue_gray1)));

Shubham Jain
- 2,365
- 2
- 17
- 29
-
if your using android.support.v7.app.ActionBar then use getSupportActionBar() in the place of getActionBar – Shubham Jain Sep 02 '15 at 11:49
-1
I think this other dicussion will be helpful to you: