7

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?)

Community
  • 1
  • 1
ateiob
  • 9,016
  • 10
  • 44
  • 55

2 Answers2

2

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

ateiob
  • 9,016
  • 10
  • 44
  • 55
0

Hmm, if there weren't an "android" tacked on to the beginning of that, I would say that no, it's not a FEATURE_CUSTOM_TITLE, as it's not a system title bar. With the "android" in there, I really don't know.

It looks sorta like something I've done before, which is running with android:theme="@android:style/Theme.NoTitleBar" in the manifest and then creating a titlebar like view at the top of each layout.

Barak
  • 16,318
  • 9
  • 52
  • 84