Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

user interface - Custom Title Bar with Progress in Android

I was wondering if there was any way to feature a custom title with my own drawable -- and then subsequently put a progress bar in the title layout so that it acts like the built in android progress bar.

In my code -- I want to be able to call setProgressBarIndeterminateVisibility(true) and have that display the progress bar in my custom title bar.

Is this possible?

I have set up my application theme so that it uses a custom title -- but I don't how or where to put the progress bar in that layout.

Thanks in advance.

EDIT: Right now I use my own theme that looks something like this:

<style parent="android:Theme.Light.NoTitleBar" name="BaseTheme">
    <item name="android:windowBackground">@drawable/splash_bg</item>
    <item name="android:windowTitleStyle">@style/TitleBackground</item>
</style>

With the title background style as :

<style name="TitleBackground" parent="android:WindowTitleBackground">
    <item name="android:background">@drawable/title_bar</item>
</style>

To give everyone a better idea -- something like this. alt text

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Add this code in onCreate before any other code:

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS);  

setProgress(xx); // Then use this to update the progress to xx amount

To turn on/off use

setProgressBarIndeterminateVisibility(false);  //true to turn on.

I have used this in a login Activity, my problem is that I run most of the login async so I having problems updating the UI. But I do get the circular progress animation to display.

I have this working on a TabActivity being updated from an async call within an Activity Intent started by the TabActivity. I had to put the "requestWind...." lines in both the TabActivityand the called Activity. Also I have found using setProgress wasn't doing much, but the spinner animation was "spinning" the whole time so I'm happy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...