Combine custom title with FEATURE_PROGRESS

我只是一个虾纸丫 提交于 2019-12-29 01:37:37

问题


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

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

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!")
}

But as soon as I call that requestWindowFeature(Window.FEATURE_CUSTOM_TITLE) I get an:

AndroidRuntimeException: You cannot combine custom titles with other title features

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

Any idea how to work around this?

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().

Is this possible?


回答1:


As documentation says:

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



来源:https://stackoverflow.com/questions/11254366/combine-custom-title-with-feature-progress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!