是否有可能改变活动的标题栏的颜色而不FEATURE_CUSTOM_TITLE? [英] Is it possible to change the color of activity's title bar without FEATURE_CUSTOM_TITLE?

查看:259
本文介绍了是否有可能改变活动的标题栏的颜色而不FEATURE_CUSTOM_TITLE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我已经找到了改变的活动的标题栏的颜色(即一个通过<一个访问的所有解决方案href=\"http://developer.android.com/reference/android/app/Activity.html#setTitle%28int%29\">activity.setTitle()和<一个href=\"http://developer.android.com/reference/android/app/Activity.html#setProgress%28int%29\">activity.setProgress())要求一个 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:

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

不过,我已经使用 FEATURE_PROGRESS 和Android不允许对组合与其他标题功能的自定义标题(由AndroidRuntimeException的方式),我不想放弃那该多好进度扎那是我的活动的一个组成部分。

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.

有关更改活动标题栏的颜色而不FEATURE_CUSTOM_TITLE的可能性,唯一的线索是另一个线程SO

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

但是,如果我尝试使用code作为是, android.R.id.titlebar 解决不了!

我在哪里可以找到 android.R.id.titlebar

我必须将它定义自己? (如果答案是肯定的,不是本在本质上是FEATURE_CUSTOM_TITLE?)

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

推荐答案

简答题(现在,直到一个更好的答案到来):

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

这篇关于是否有可能改变活动的标题栏的颜色而不FEATURE_CUSTOM_TITLE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆