结合自定义标题与FEATURE_PROGRESS [英] Combine custom title with FEATURE_PROGRESS

查看:155
本文介绍了结合自定义标题与FEATURE_PROGRESS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的onCreate()我设置一个进度条如下:

In my onCreate() I set a progress bar as follows:

getWindow().requestFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

现在,希望加强这种标题栏一点点,我想改变它的背景的颜色。第一步是检查 FEATURE_CUSTOM_TITLE 支持:

Now, wishing to enhance that title bar a little bit, I want to change its background color. First step is to check if FEATURE_CUSTOM_TITLE is supported:

final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
if ( customTitleSupported ) {
    Log.i(TAG, "CUSTOM TITLE SUPPORTED!")
}

但只要我称之为 requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)我得到一个:

AndroidRuntimeException: You cannot combine custom titles with other title features

(这并不重要,如果我设置之前调用此函数 FEATURE_PROGRESS 或之后)

(It doesn't matter if I call this function before setting FEATURE_PROGRESS or after)

不知道如何解决呢?

或者,我会避免定制的标题栏,如果我能找到的非定制标题栏的资源 ID 。东西是不是危险的getParent()更好。

Alternatively, I would avoid a custom title bar, if I could find the non-custom title bar's resource ID. Something that's better than the dangerous getParent().

这可能吗?

推荐答案

作为的文件说

FEATURE_CUSTOM_TITLE

FEATURE_CUSTOM_TITLE

标记的自定义标题。不能将这个   功能与其他标题的功能。

Flag for custom title. You cannot combine this feature with other title features.

什么,你提到你可以做的是使用一个进度条的自定义标题栏,的下面是一个例子如何实现这一目标

What you can do as you mentioned is to use a custom title bar with a ProgressBar, here is an example how to accomplish that.

在另一方面,你为什么不使用操作栏?

In the other hand, why aren't you using Action Bar?.

这篇关于结合自定义标题与FEATURE_PROGRESS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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