How to Change the ProgressBar Color in Android? Last Updated : 23 Feb, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 operation. Note in this article we will be using Java and XML to set the color. Step by Step ImplementationStep 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. Note that select Java as the programming language. Step 2: Create a custom ProgressBar Go to the app > res > drawable > right-click > New > Drawable Resource File and name the file as progress_bg.Inside the XML file add a rotate tag with some attributes(see code)Inside rotate tag create a shape tag within which create the size and gradient tagAttributes of these tags are given in the code below. Below is the code for the progress_bg.xml file. XML <?xml version="1.0" encoding="utf-8"?> <!--use rotate tag to rotate the drawable--> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="0" android:pivotX="50%" android:pivotY="50%" android:toDegrees="360"> <!--shape tag is used to build a shape in XML--> <shape android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="8" android:useLevel="false"> <!--set the size of the shape--> <size android:width="76dip" android:height="76dip" /> <!--set the color gradients of the shape--> <gradient android:angle="0" android:endColor="#00ffffff" android:startColor="#447a29" android:type="sweep" android:useLevel="false" /> </shape> </rotate> Step 3: Working with the activity_main.xml file Go to the activity_main.xml file and refer to the following code. Open the activity_main.xml file and in the ProgressBar tag and set the drawable in indeterminateDrawable attribute. Below is the code for the activity_main.xml file. XML <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="20dp"> <!--set the custom progress bar here in the indeterminateDrawable attribute--> <ProgressBar android:id="@+id/ProgressBar01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:indeterminate="true" android:indeterminateDrawable="@drawable/progress_bg" android:progress="0" /> <Button android:id="@+id/show_button" android:layout_width="191dp" android:layout_height="wrap_content" android:layout_below="@id/ProgressBar01" android:layout_centerHorizontal="true" android:layout_marginTop="80dp" android:text="Progress Bar" /> </RelativeLayout> Step 4: Working with the MainActivity.java file Go to the MainActivity.java file and refer to the following code. Below is the code for the MainActivity.java file. Comments are added inside the code to understand the code in more detail. Java import android.os.Bundle; import android.os.Handler; import android.widget.Button; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { Handler handler = new Handler(); public static Button button; public static TextView textView; public static ImageView img1, img2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // create a progress bar variable and set the id final ProgressBar progressBar = findViewById(R.id.ProgressBar01); // show the progress bar progressBar.getProgress(); } } Output: Comment More infoAdvertise with us Next Article How to Change the Color of Status Bar in an Android App? N namanjha10 Follow Improve Article Tags : Android Android-Bars Similar Reads How to Change the ListView Text Color in Android? In Android, a ListView is a UI element used to display the list of items. This list is vertically scrollable and each item in the ListView is operable. A ListView adapter is used to supply items from the main code to the ListView in real-time. By default, the TextView font size is 14 sp and color is 3 min read How to Change Color of Logcat in Android Studio? In this article, you will see how to change the color of Logcat. Before moving further let's know about Logcat. A Logcat is a command-line tool that dumps the system log messages. Suppose you are developing an application that contains 3000 lines of code and now after running the application it cras 2 min read How to Change the Color of Status Bar in an Android App? A Status Bar in Android is an eye-catching part of the screen, all of the notification indications, battery life, time, connection strength, and plenty of things are shown here. An Android user may look at a status bar multiple times while using an Android application. It is a very essential part of 4 min read How to Implement Circular ProgressBar in Android? ProgressBar is used when we are fetching some data from another source and it takes time, so for the user's satisfaction, we generally display the progress of the task. In this article, we are going to learn how to implement the circular progress bar in an Android application using Java. So, this ar 5 min read How to change the color of Action Bar in an Android App? Customizing the Action Bar allows you to enhance the visual appeal of your Android app. In this article, you will learn how to change the colour of the Action Bar in an Android App. Basically, there are two ways to change color.By changing styles.xml file:Just go to res/values/styles.xml fileedit th 2 min read How to Make SpinKit Progress Bar in Android? In this article Custom Progress Bar in Android, we have discussed some good And captivating Progress Bar that is used in many Google Apps. In this article, we are going to add some more Custom Progress Bar For Android using the Android-SpinKit library. In simpler terms, Progress Bar is a visual repr 4 min read Like