Android custom title bar

I was wondering if there is any way to create my own header with my own drawable, and then put the progress bar in the header layout so that it works as a built-in Android progress indicator.

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

Is it possible?

I configured my application theme to use a custom header, but I don’t know how and where to put the progress bar in this layout.

Thanks in advance.

EDIT: right now I'm using my own theme, which 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 header background type 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

+7
android user-interface
source share
4 answers

I believe the only way to do this is to use your own title bar. You CAN override Android code from the moment it was opened - but that might be a bad idea. It’s best to make a header layout and simply <include /> it in all other layouts and possibly have a helper class to show and hide the progress bar.

+3
source share

Add this code to 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 enable / disable use

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

I used this in my account, my problem is that I run most of the asynchronous login, so I have problems updating the user interface. But I get an animation of circular progress to display.

I have work on updating TabActivity from an asynchronous call as part of an Activity Intent launched by TabActivity. I had to put the lines "requestWind ...." in both TabActivity and the called activity. I also found that using setProgress is not very much, but the spinner animation has been "spinning" all the time, so I'm happy.

+12
source share

Here's a great example of how to implement a custom title bar with a progress bar:

http://downloadandroid.info/2010/08/creating-a-custom-titlebar/

My solution is to have an ActivityHelper class that extends the Activity and enables this method, as well as one to turn the progress bar on or off, and then extend this class from each of my activities.

+4
source share

In newer versions, the requestWindowFeature technique will not work. A better option would be to use v7.widget.toolbar, which was provided by Google. The following link provides the correct information on how to use it.

Action bar customization

http://developer.android.com/training/appbar/setting-up.html

0
source share

All Articles