Android ProgressBar Tutorial with Example

By | April 17, 2019

What is ProgressBar ?

Progress Bar is used to show progress of task.It is graphical view indicator that shows some progress. Progress Bar is a user interface element that indicates the progress of operation.

Progress bar supports two modes of progress :
determinate and indeterminate.

What is determinate process ?

Determinate process is a show that a specific quantity of progress.For Example. Percent remaining of a file being retrieved.In this process to user to display of percent Like Downloading or Uploading File.

What is indeterminate process ?

Indeterminate process is a progress of do not know how long an operation it will take.For Example You can Download Or Upload file but it does not show background process and does not know how long downloading time it will take.

Progress Bar Attributes

Progress bar important attribute to use implementation of progress bar.

android:max : It is used to set maximum value of default progressbar maximum value is 100.

android:indeterminate : it is used to boolean value set depending on weather the time is determinate or not.

android:progress : it is used to set the number of progressbar value will be incremented.

android:style : it is used horizontal bar or vertical bar style.set the attribute of style ?android:attr/progressBarStyleHorizontal .

android:minwidth : it is used to set the width of progressbar.

android:minHeight : it is used to set the height of progressbar.

Implementation of Progressbar

I have Implementation of Progressbar in android.Create New activit_main.xml file.Write And Follow Code

Create File

Now above the code of created progressbar and button in xml file.and implement id by progressbar and button.when user to click on button to create thread and implement override method is run() and i have put for loop on 100 times and display progress percentage of 10 time beacuse of i of increment is i+10 time.when every time for loop execute to wait for 500 milisecond on progress.i have use to sleep() method to wait a thread on every time to hold progress.