Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Java
  • Android
  • Kotlin
  • Flutter
  • Dart
  • Android with Java
  • Android Studio
  • Android Projects
  • Android Interview Questions
Open In App
Next Article:
State ProgressBar in Android
Next article icon

State ProgressBar in Android

Last Updated : 09 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

State Progress Bar is one of the main features that we see in many applications. We can get to see this feature in ticket booking apps, educational apps. This progress bar helps to tell the user the steps to be carried out for performing a task. In this article, we are going to see how to implement State Progress Bar in Android.

Application of State Progress Bar

  • Used in most of the service providing applications such as ticket booking, exam form filling, and many more.
  • This State Progress Bar helps the user's steps to be carried out for performing the task.
  • Use in various exam form-filling applications.

Attributes of State Progress Bar

Attributes

Description

layout_widthUse for giving specific width.
layout_heightUse for giving specific height.
spb_maxStateNumberUse to display the number of states used in the app.
spb_currentStateNumberUse to display the current state.
spb_stateBackgroundColorUse to display background color.
spb_stateForegroundColorUse to display Foreground color.
spb_animateToCurrentProgressStateGives Animation to the current Progress state.
spb_checkStateCompletedCheck whether the state is completed or not. 


Step by Step Implementation

Step 1: Create a New Project

To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.

Step 2: Add dependency

Navigate to Gradle Scripts > build.gradle.kts(Module :app) and add the following dependency under the dependencies {} section.

dependencies {
...
implementation ("com.github.kofigyan:StateProgressBar:69b4192777") {
exclude(group = "com.android.support", module = "support-v4")
}
}

Navigate to Gradle Scripts > settings.gradle.kts and add the following code under the repositories{} section.

dependencyResolutionManagement {
...
repositories {
...
maven { url = uri("https://jitpack.io") }
}
}

Navigate to Gradle Scripts > gradle.properties and add the following code at the end.

android.enableJetifier=true

Now click on Sync now.


Step 3: Create a new State Progress Bar in your activity_main.xml file

Navigate to the app > res > layout > activity_main.xml file. Below is the code for the activity_main.xml file.

activity_main.xml:

XML
<?xml version="1.0" encoding="utf-8"?> <LinearLayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"     android:gravity="center"     tools:context=".MainActivity">      <!--Progress Bar created-->     <com.kofigyan.stateprogressbar.StateProgressBar         android:id="@+id/your_state_progress_bar_id"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         app:spb_animateToCurrentProgressState="true"         app:spb_checkStateCompleted="true"         app:spb_currentStateDescriptionColor="#0F9D58"         app:spb_currentStateNumber="one"         app:spb_maxStateNumber="four"         app:spb_stateBackgroundColor="#BDBDBD"         app:spb_stateDescriptionColor="#808080"         app:spb_stateForegroundColor="#0F9D58"         app:spb_stateNumberBackgroundColor="#808080"         app:spb_stateNumberForegroundColor="#eeeeee" />      <!--Button to go on next step-->     <Button         android:id="@+id/button"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_marginTop="16dp"         android:text="NEXT" />  </LinearLayout> 


Step 4: Working with the MainActivity file

Go to the MainActivity file and refer to the following code. Below is the code for the MainActivity file. Comments are added inside the code to understand the code in more detail.

MainActivity.java
package org.geeksforgeeks.demo;  import android.os.Bundle; import android.view.View; import android.widget.Button;  import androidx.appcompat.app.AppCompatActivity;  import com.kofigyan.stateprogressbar.StateProgressBar;  public class MainActivity extends AppCompatActivity {      // steps on state progress bar     String[] descriptionData = {"Step One", "Step Two", "Step Three", "Step Four"};      Button button;      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);          StateProgressBar stateProgressBar = (StateProgressBar) findViewById(R.id.your_state_progress_bar_id);         stateProgressBar.setStateDescriptionData(descriptionData);          // button given along with id         button = (Button) findViewById(R.id.button);          button.setOnClickListener(new View.OnClickListener() {             @Override             public void onClick(View view) {                 switch (stateProgressBar.getCurrentStateNumber()) {                     case 1:                         stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.TWO);                         break;                     case 2:                         stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.THREE);                         break;                     case 3:                         stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.FOUR);                         break;                     case 4:                         stateProgressBar.setAllStatesCompleted(true);                         break;                 }             }         });     } } 
MainActivity.kt
package org.geeksforgeeks.demo  import android.os.Bundle import android.view.View import android.widget.Button import androidx.appcompat.app.AppCompatActivity import com.kofigyan.stateprogressbar.StateProgressBar   class MainActivity : AppCompatActivity() {      // steps on state progress bar     private var descriptionData: Array<String> = arrayOf("Step One", "Step Two", "Step Three", "Step Four")     private var button: Button? = null      override fun onCreate(savedInstanceState: Bundle?) {         super.onCreate(savedInstanceState)         setContentView(R.layout.activity_main)          val stateProgressBar =             findViewById<View>(R.id.your_state_progress_bar_id) as StateProgressBar         stateProgressBar.setStateDescriptionData(descriptionData)          // button given along with id         button = findViewById<View>(R.id.button) as Button          button!!.setOnClickListener {             when (stateProgressBar.currentStateNumber) {                 1 -> stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.TWO)                 2 -> stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.THREE)                 3 -> stateProgressBar.setCurrentStateNumber(StateProgressBar.StateNumber.FOUR)                 4 -> stateProgressBar.setAllStatesCompleted(true)             }         }     } } 


Output:


Next Article
State ProgressBar in Android

C

chinmaymunje96
Improve
Article Tags :
  • Java
  • Technical Scripter
  • Android
  • Technical Scripter 2020
  • Kotlin Android
  • Android-Bars
  • Android-projects
  • Java-Android
Practice Tags :
  • Java

Similar Reads

    ProgressBar in Android
    Progress Bar are used as loading indicators in android applications. These are generally used when the application is loading the data from the server or database. There are different types of progress bars used within the android application as loading indicators. In this article, we will take a lo
    3 min read
    How to Change the ProgressBar Color in Android?
    In this article, we will see how we can add color to a ProgressBar in android. Android ProgressBar is a user interface control that indicates the progress of an operation. For example, downloading a file, uploading a file on the internet we can see the ProgressBar estimate the time remaining in oper
    3 min read
    ProtractorView in Android
    In this article, ProtractorView is added to android. ProtractorView is a semicircular Seekbar view for selecting an angle from 0° to 180. Seek bar is a type of progress bar. Change the cursor from 0° to 180 for selecting an angle. Below is the image of ProtractorView. Step By Step ImplementationStep
    3 min read
    ProgressBar in Android using Jetpack Compose
    ProgressBar is a material UI component in Android which is used to indicate the progress of any process such as for showing any downloading procedure, as a placeholder screen, and many more. In this article, we will take a look at the implementation of ProressBar in Android using Jetpack Compose.Att
    3 min read
    Custom Progress Bar in Android
    ProgressBar is generally used for loading a screen in WebView or indicating a user to wait. We can make that progress bar look fancy and this progress bar is mainly used in some of the popular Google apps. It is very convenient and easy to implement. A sample video is given below to get an idea abou
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences