Friz14
Friz14

Reputation: 278

How to change title bar color without theme

How I can change background color of titlebar without using theme. tnks in Android.

Upvotes: 5

Views: 4644

Answers (3)

Shubham Jain
Shubham Jain

Reputation: 2383

ActionBar bar = getActionBar(); bar.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.material_blue_gray1)));

Upvotes: 0

Sunil Kumar Sahoo
Sunil Kumar Sahoo

Reputation: 53657

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

Upvotes: 4

kikoso
kikoso

Reputation: 708

I think this other dicussion will be helpful to you:

Set title background color

Upvotes: -1

Related Questions