‫Welcome back.
‫In this video we're going to learn about Progress bars.
‫A progress bar is a UI component used to indicate the progress of an ongoing operation, or to visually
‫represent the completion of a task.
‫It's commonly used to show users that some work is being done in the background, and it comes in different
‫styles, such as determinate and indeterminate.
‫To create a progress bar, let's go to the layout and here I'll start with the progress bar.
‫I'll set wrap content, wrap content, and I'll give it an ID as my progress bar.
‫You can see this is our progress bar.
‫I'll drag and drop it to here and infer the constraints.
‫This is a circular progress bar.
‫If you don't know the specific progress value, you can use the indeterminate progress bar to indicate
‫that some operation is in progress.
‫If we run the program now, we can see this indeterminate progress bar it's running.
‫So you need to control its visibility when working with progress.
‫If you know the progress, you need to replace it with determinate progress bar.
‫Of course you can change the style of this progress bar.
‫So I can add style equals to Android attribute.
‫And I'll select progress bar style horizontal.
‫And here we go.
‫We changed the progress bar from a circular to a horizontal one.
‫I'll infer the constraints like this and I'll make the width as matchparent you can see it.
‫Also, you can put zero dp to match the constraints.
‫You can see that this progress bar is matching the constraints.
‫Now let's move to the main activity and initialize this progress bar.
‫I'll create a new function called Display progress bar, and inside this function I'll initialize this
‫progress bar val progress bar.
‫It's of type progress bar equals.
‫To find view by id or id dot my progress bar, you can set the progress value for a determinate progress
‫bar.
‫For example, if you are downloading a file, you might update the progress as the downloaded progress.
‫For example, val progress value equals to 60 progress bar dot progress equals to progress value.
‫Let me run I need to call this method in the Oncreate method.
‫Run again and here we go.
‫We are setting 60% completed for the value for the progress value of this progress bar.
‫So this is representing 60 over 100 as a progress for this progress bar.
‫So this is how we create progress bars in Android and how to control the progress of these progress
‫bars.