30

I am creating a ProgressBar in my app programmatically it is of SPIN style by default however I want it in HORIZONTAL style. I don't see any method/constant to achieve this.

And I don't want to use ProgressDialog as it'd be inconsistent with my App UI theme.

Any suggestions please?

Jonik
  • 80,077
  • 70
  • 264
  • 372
iuq
  • 1,487
  • 1
  • 20
  • 42
  • you haven't read this http://developer.android.com/guide/topics/ui/dialogs.html – MKJParekh Jan 04 '12 at 13:16
  • 1
    that explains ProgressDialog while I am appending ProgressBar directly in my view. It appears but not in Horizontal style. Please correct me if I missed anything in the link you suggested. – iuq Jan 04 '12 at 13:24
  • I think there is something titled under **"Showing a progress bar"** can help you. – MKJParekh Jan 04 '12 at 13:27
  • that article explains about ProgressDialog but not ProgressBar – waqaslam Jan 04 '12 at 14:50

2 Answers2

92

use this:

ProgressBar pb = new ProgressBar(context,
                                 null, 
                                 android.R.attr.progressBarStyleHorizontal);
MKJParekh
  • 34,073
  • 11
  • 87
  • 98
waqaslam
  • 67,549
  • 16
  • 165
  • 178
3

If you are using a ProgressDialog then, here is a way to change the style of the progressBar in the ProgressDialog.

mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
amalBit
  • 12,041
  • 6
  • 77
  • 94