ProgressBar: ProgressBar is used to display the status of work being done like analyzing status of work or downloading a file etc. 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.

Step 1: Open up Android Studio Project through res -> layout -> activity_main.xml (or) main.xml and add below code or just drag and drop the switch to design XML file.

Step 2: Add below code in MainActivity.java.