How to change ProgressBar's progress indicator color in Android

android progressbar
how to change circular progress bar color in android
change progressbar color android
android change progressbar color programmatically
horizontal progress bar android
custom circular progress bar in android
custom horizontal progress bar in android
android:progress bar style

I have set Horizontal ProgressBar.

I would like to change the progress color to yellow.

<ProgressBar 
    android:id="@+id/progressbar" 
    android:layout_width="80dip" 
    android:layout_height="20dip"  
    android:focusable="false" 
    style="?android:attr/progressBarStyleHorizontal" />

The problem is, the progress color is different in different devices. So, I want it to fix the progress color.

I copied this from one of my apps, so there's prob a few extra attributes, but should give you the idea. This is from the layout that has the progress bar:

<ProgressBar
    android:id="@+id/ProgressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:indeterminate="false"
    android:maxHeight="10dip"
    android:minHeight="10dip"
    android:progress="50"
    android:progressDrawable="@drawable/greenprogress" />

Then create a new drawable with something similar to the following (In this case greenprogress.xml):

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape>
            <corners android:radius="5dip" />
            <gradient
                android:angle="270"
                android:centerColor="#ff5a5d5a"
                android:centerY="0.75"
                android:endColor="#ff747674"
                android:startColor="#ff9d9e9d" />
        </shape>
    </item>

    <item android:id="@android:id/secondaryProgress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                    android:angle="270"
                    android:centerColor="#80ffb600"
                    android:centerY="0.75"
                    android:endColor="#a0ffcb00"
                    android:startColor="#80ffd300" />
            </shape>
        </clip>
    </item>
    <item android:id="@android:id/progress">
        <clip>
            <shape>
                <corners android:radius="5dip" />
                <gradient
                    android:angle="270"
                    android:endColor="#008000"
                    android:startColor="#33FF33" />
            </shape>
        </clip>
    </item>

</layer-list>

You can change up the colors as needed, this will give you a green progress bar.

How to change ProgressBar's progress indicator color in Android , If you only want to change the progress bar color, you can simply use a color filter in your Activity's onCreate() method: ProgressBar progressbar = (ProgressBar) findViewById(R. id. progressbar); int color = 0xFF00FF00; progressbar. To increase the progress bar by a fixed value. Set the ProgressBar control's Minimum and Maximum values. Set the control's Step property to an integer representing the amount to increase the progress bar's displayed value. Call the PerformStep method to change the value displayed by the amount set in the Step property.

A simpler solution:

progess_drawable_blue

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
    <shape>
        <solid
                android:color="@color/disabled" />
    </shape>
</item>

<item
    android:id="@android:id/progress">
    <clip>
        <shape>
            <solid
                android:color="@color/blue" />
        </shape>
    </clip>
</item>

</layer-list>

How to change color in circular progress bar?, In the res/drawable folder, put this: progress.xml. <?xml version="1.0" encoding=" utf-8"?> <rotate� How to set ProgressBar theme style dynamically using getProgressDrawable() setColorFilter method. Progress bar style theme can be easily changeable through some methods. So here is the complete step by step tutorial for Change progress bar color in android programmatically.

Just create a style in values/styles.xml.

<style name="ProgressBarStyle">
    <item name="colorAccent">@color/greenLight</item>
</style>

Then set this style as your ProgressBar theme.

<ProgressBar
    android:theme="@style/ProgressBarStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

and doesn't matter your progress bar is horizontal or circular. That's all.

ProgressBar, I'm using standard horizontal progress bar <ProgressBar android:id="@+id/ progressBarWaitingObjects" style="@style/Widget.AppCompat. To create a custom ProgressBar you need to override the OnPaint method, then add the code following to change your ProgressBar color. progressBar.ForeColor = Color.FromArgb(125, 0, 0); progressBar.BackColor = Color.FromArgb(170, 0, 0);

If you only want to change the progress bar color, you can simply use a color filter in your Activity's onCreate() method:

ProgressBar progressbar = (ProgressBar) findViewById(R.id.progressbar);
int color = 0xFF00FF00;
progressbar.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);
progressbar.getProgressDrawable().setColorFilter(color, PorterDuff.Mode.SRC_IN);

Idea from here.

You only need to do this for pre-lollipop versions. On Lollipop you can use the colorAccent style attribute.

How to change color of horizontal progress bar? � Issue #218 , I am using circular progress bar on Android. I wish to change the color of this. I am using "?android:attr/progressBarStyleLargeInverse". style. So how to change � Usually, the color of the progressbar is green. Now, we will create a program that changes the progressbar color in vb.net. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows

for API level 21 or higher just use

android:progressBackgroundTint="@color/yourBackgroundColor"
android:progressTint="@color/yourColor"

How to change color in circular progress bar?, How to change Progress bar color in android? Please make one xml file name progress.xml and put it in res/xml folder and write the below� Note: Progress bars are not supported in Internet Explorer 9 and earlier (because they use CSS3 transitions and animations to achieve some of their effects). Note: To help improve accessibility for people using screen readers, you should include the aria-* attributes.

Change progress bar color in android, the progress bar. So let's change the state by adding the max and value attribute. It only allows changing the color of the progress bar value. IE implements� The reason is because I'm creating the progress bar dynamically, and setting its color upon user request. Since I usually use code for building my GUI screen and components, I'm not familiar with the attached XML and I don't know what's a layer-list (although I'm guessing that you are building the progress bar based on several layers..).

The HTML5 progress Element, How to change ProgressBar color programmatically in Android. activity_main.xml . <RelativeLayout xmlns:android="http://� In this article, We will create a simple Login Form and we will change the color of the ProgressBar. If entered password lower then 5 characters, we will set the color of progress bar as red . And if entered chars are between 5 And 8 we will set the color of progressbar is yellow.

How to change ProgressBar color programmatically in Android, HTML Changing the color of a progress bar. Example#. Progress bars can be styled with the progress[value] selector. So, if you want to customize the color of the bar, you would need to disabling theming/styling for the ProgressBar, or else draw the bar manually (I once found an article that explained how to manually blend a color image on top of the Win32 theme drawing to get the desired bar color, I think it was on codeproject.com, but I can't find it now).

Comments
  • above answers change the whole background color and it's ambigios that it change the height of progress bar to very max.which unable to change in xml. better way to change only progress bar status that how much is completed i.s 20% red color, 50% yellow color 70% and above green color. you can do it programmatically in java. share your answer if you have any other solution.
  • And also i remove this android:indeterminate="false"
  • Please help me. I try to create greenprogress.xml by copy your code but the Android Studio 0.4.6 mark <layer-list> as and error "Element-list must be declared" what should I do?
  • Is it possible to change the colour dynamically?
  • can the colour be changed depending on current progress value defined in the actual bar?
  • @Ryan It would be helpful to explain what android:id="@android:id/progress", android:id="@android:id/background" and android:id="@android:id/secondaryProgress" stand for.
  • here @color/disabled is a custom color
  • Or <solid android:color="@android:color/black" />, or even <solid android:color="#ff33b5e5" />
  • This is enough android:indeterminateTint="@color/white" for API lever 21 and above
  • Wow, the simpliest solution, works for me. I wondered why this answer has so many votes.
  • For SeekBar it is the same, just add for API 16: seekBar.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN);. This will change the colour of that round thumb.
  • Calling setColorFilter() on a drawable directly will apply the colour everywhere. Since this is what I didn't need, I just called mutate() on the Drawable (i.e like seekBar.getThumb().mutate().setColorFilter(color, PorterDuff.Mode.SRC_IN);
  • I've seen this solution elsewhere but all it does (testing on a Gingerbread device) is turn the entire progress bar that one color, making it impossible see the actual progress