Question: I've got progress\_incomplete.xml and progress\_complete.xml

Both files are like this (I removed all the gradients and stroke info to save room as its not really important).

Basically the incomplete.xml has yellow colours and complete has green colours.

```
<?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>
        ...
    </shape>
</item>

<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape>
         ...
        </shape>
    </clip>
</item>
<item
    android:id="@android:id/progress"
>
    <clip>
        <shape>
          ...
        </shape>
    </clip>
</item>

</layer-list>

```

In my Java file, I have this:

```
            if (percentage == 100)
            {
                // Change colour
                progressBar.setProgressDrawable(R.drawable.progress_complete);
            }

```

I'm finding this isn't working though. I've also tried setBackground and setBackgroundDrawable but the change isn't taking effect.

What do I do?

Thanks

Answer: 
```
if (percentage == 100) {
    // Change colour
    Drawable drawable = getResources().getDrawable(R.drawable.progress_complete);
    progressBar.setProgressDrawable(drawable);
}

```
Refering [this](https://stackoverflow.com/questions/2805866/android-progressbar-setprogressdrawable-only-works-once) answer on SO, you may try this solution. It may fix you problem.

```
if (percentage == 100)

    {
        // Change colour
        Rect bounds = progressBar.getProgressDrawable().getBounds();
        progressBar.setProgressDrawable(R.drawable.progress_complete);
        progressBar.getProgressDrawable().setBounds(bounds);
    }

```