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

2

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://mcmap.net/q/112892/-set-title-background-color

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

Mortician answered 29/6, 2012 at 14:39 Comment(0)
M
2

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

Mortician answered 24/10, 2012 at 19:40 Comment(0)
F
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.

Feces answered 29/6, 2012 at 16:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.