Android Progress Dialog Style

Moving ahead from simple progress dialog example here we are going to see about how to view progress dialog in different style.

There are 2 styles available for progress dialog

  • ProgressDialog.STYLE_SPINNER
  • ProgressDialog.STYLE_HORIZONTAL

Default style for progress dialog is ProgressDialog.STYLE_SPINNER. Now we are going to see another progress dialog style ( ProgressDialog.STYLE_HORIZONTAL ) .

The output looks similar to

Horizontal style helps us to show the progress value. For eg:- 22/100 completed. So user can easily know when the progress will completed.

[sourcecode language="java"]
ProgressDialog progressDialog = new ProgressDialog(this);
progressDialog.setProgress(10);
progressDialog.setSecondaryProgress(32);
progressDialog.setMax(150);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMessage("Loading Data...");
progressDialog.show();
[/sourcecode]

setMax() is used to set the progress maximum value.
setProgressStyle() is used to set style for progress dialog.
setSecondaryProgress() is used to set the progress value.