Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the color of activity's title bar without FEATURE_CUSTOM_TITLE?

All the solutions I have found so far for changing the color of the activity's title bar (i.e. the one accessed via activity.setTitle() and activity.setProgress()) mandate a FEATURE_CUSTOM_TITLE:

https://stackoverflow.com/a/2285722/869501

But I am already using FEATURE_PROGRESS and Android forbids combining custom titles with other title features (by way of AndroidRuntimeException) and I don't want to give up that nice progress bar that's an integral part of my activity.

The only hint about a possibility of changing the color of activity's title bar without FEATURE_CUSTOM_TITLE was in another SO thread:

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

But if I try to use the code as is, android.R.id.titlebar cannot be resolved!

Where do I find that android.R.id.titlebar?

Do I have to define it myself? (if the answer is yes, isn't this in essence a FEATURE_CUSTOM_TITLE?)

like image 294
ateiob Avatar asked Jun 29 '12 14:06

ateiob


1 Answers

Short answer (for now, until a better answer comes along): No.

like image 170
ateiob Avatar answered Nov 18 '22 13:11

ateiob