Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

android - Combine custom title with FEATURE_PROGRESS

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...