Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create 'Horizontal style' progress bar programmatically in Android?

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?

like image 480
iuq Avatar asked Jan 04 '12 12:01

iuq


People also ask

How do I make my progress bar horizontal android?

In Android, by default a progress bar will be displayed as a spinning wheel but If we want it to be displayed as a horizontal bar then we need to use style attribute as horizontal. It mainly use the “android. widget. ProgressBar” class.

How do I automatically display progress bar on each retrofit API call?

ProgressDialog mProgressDialog = new ProgressDialog(this); mProgressDialog. setIndeterminate(true); mProgressDialog. setMessage("Loading..."); mProgressDialog. show(); retrofitService.

What is ProgressBar in android?

Android ProgressBar is a graphical view indicator that shows some progress. Android progress bar displays a bar representing the completing of the task. Progress bar in android is useful since it gives the user an idea of time to finish its task.

Which of the following can you use to display a progress bar in an android application?

app. ProgressDialog class to show the progress bar. Android ProgressDialog is the subclass of AlertDialog class. The ProgressDialog class provides methods to work on progress bar like setProgress(), setMessage(), setProgressStyle(), setMax(), show() etc.


1 Answers

use this:

ProgressBar pb = new ProgressBar(context,                                  null,                                   android.R.attr.progressBarStyleHorizontal); 
like image 131
waqaslam Avatar answered Sep 19 '22 03:09

waqaslam