24

What's the best way to create an indeterminate, horizontal progress bar? If I do this,

    dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    dialog.setIndeterminate(true);

I still get the progress numbers (percent, etc) along the bottom. On ICS, I can do this,

    dialog.setProgressNumberFormat("");
    dialog.setProgressPercentFormat(new NumberFormat() {

        @Override
        public StringBuffer format(double value, StringBuffer buffer, FieldPosition field) {
            return new StringBuffer();
        }

        @Override
        public StringBuffer format(long value, StringBuffer buffer, FieldPosition field) {
            return new StringBuffer();
        }

        @Override
        public Number parse(String string, ParsePosition position) {
            return 0;
        }
    });

to get rid of the numbers at the bottom, but those two methods are only available on ICS.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134

3 Answers3

70

Here we go - I just found it. :) android:indeterminateOnly="true" is the key.

    <ProgressBar
        android:id="@+id/progressBar1"
        style="?android:attr/progressBarStyleHorizontal"
        android:indeterminateOnly="true" 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
GulBrillo
  • 901
  • 7
  • 9
-1

I think you should probably use spinning wheel mode for indeterminate mode, as the horizontal progress bar may mislead the user that in fact the mode is not indeterminate.

Please look at the documentation for ProgressBar Note that there is an Indeterminate Only mode that you can perhaps try.

Rémi F
  • 1,327
  • 12
  • 25
  • 5
    i am sure i can do it if i build the dialog myself with a `ProgressBar`. i think you are wrong about using the spinning wheel. android has graphic assets for indeterminate horizontal progress bars and it's used extensively the stock UI. – Jeffrey Blattman May 22 '12 at 16:53
  • ok. so I understand you want to use this "activity bar" (like in Google Play) : http://developer.android.com/design/building-blocks/progress.html – Rémi F May 24 '12 at 07:16
  • i do, but i'm wondering how to get that in a progress dialog. – Jeffrey Blattman Jun 18 '12 at 16:36
-1

A horizontal progress bar which shows a gradually widening bit starting at 0% of the bar width and ends at 100% of the bar width is not indeterminate, as it appears to be ending, and it's status therefore can be determined.

So you're probably not looking for an indeterminate progress bar, but a determinate one, like the one buzeeg pointed to: http://developer.android.com/design/building-blocks/progress.html.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Daniel
  • 1
  • no, i'm not looking for an indeterminate. in the link you provided, look at the section that reads "activity bar". that's what i'm talking about. – Jeffrey Blattman Jun 16 '12 at 07:47