Android: indeterminate horizontal progress (dialog) bar

Jeffrey Blattman picture Jeffrey Blattman · May 16, 2012 · Viewed 20.6k times · Source

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.

? Thanks

Answer

GulBrillo picture GulBrillo · Dec 13, 2012

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" />