title: Android - ProgressBar setProgress() method doesn't update the progress bar drawable
body: <p>I set a circular progress bar (from 0 to 100) for showing a time running progress (from 1:00 to 0:00). When time is 1:00, the progress must be 0, when time is 0:00, the progress must be 100.</p>
  
  <pre><code>&lt;ImageView
      android:layout_width="@dimen/_56sdp"
      android:layout_height="@dimen/_56sdp"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="@dimen/_2sdp"
      android:src="@drawable/a_circular_black" /&gt;
  
  &lt;ProgressBar
      android:id="@+id/progressBar"
      style="?android:attr/progressBarStyleHorizontal"
      android:layout_width="@dimen/_56sdp"
      android:layout_height="@dimen/_56sdp"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="@dimen/_2sdp"
      android:max="100"
      android:progress="26" //I set the progress 26 to show what it will be look like. Normally for 1:00 the progress must be 0.
      android:progressDrawable="@drawable/a_circular" /&gt;
  
  &lt;TextView
      android:id="@+id/textViewTimer"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="@dimen/_17sdp"
      android:text="1:00"
      android:textColor="#000000"
      android:textSize="@dimen/_18sdp"
      android:textStyle="bold" /&gt;
  </code></pre>
  
  <p>Here's the progress bar background:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;item android:id="@android:id/progress"&gt;
          &lt;rotate
              android:fromDegrees="270"
              android:toDegrees="270"
              android:pivotX="50%"
              android:pivotY="50%" &gt;
              &lt;shape
                  android:innerRadiusRatio="2.5"
                  android:shape="ring"
                  android:thickness="@dimen/_3sdp" &gt;
                  &lt;size android:width="@dimen/_56sdp" android:height="@dimen/_56sdp" /&gt;
                  &lt;gradient
                      android:centerColor="#FFA708"
                      android:endColor="#FFA708"
                      android:startColor="#FFA708"
                      android:type="sweep" /&gt;
              &lt;/shape&gt;
          &lt;/rotate&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>Here's the image background:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item&gt;
          &lt;shape android:shape="oval"&gt;
              &lt;size
                  android:width="60dp"
                  android:height="60dp" /&gt;
              &lt;stroke
                  android:width="3dp"
                  android:color="#ccc" /&gt;
              &lt;padding
                  android:bottom="3dp"
                  android:left="3dp"
                  android:right="3dp"
                  android:top="3dp" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
      &lt;item android:id="@android:id/progress"&gt;
          &lt;rotate
              android:fromDegrees="270"
              android:pivotX="50%"
              android:pivotY="50%"
              android:toDegrees="270"&gt;
              &lt;shape
                  android:shape="oval"&gt;
                  &lt;size
                      android:width="60dp"
                      android:height="60dp" /&gt;
                  &lt;gradient
                      android:centerColor="#000"
                      android:endColor="#000"
                      android:startColor="#000"
                      android:type="sweep" /&gt;
  
                  &lt;padding
                      android:bottom="3dp"
                      android:left="3dp"
                      android:right="3dp"
                      android:top="3dp" /&gt;
              &lt;/shape&gt;
          &lt;/rotate&gt;
      &lt;/item&gt;
      &lt;item&gt;
          &lt;shape android:shape="oval"&gt;
              &lt;size
                  android:width="60dp"
                  android:height="60dp" /&gt;
              &lt;solid android:color="#ccc" /&gt;
          &lt;/shape&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;.
  </code></pre>
  
  <p>So, on my layout preview it appears like this:</p>
  
  <p><a href="https://i.stack.imgur.com/C3Z8A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C3Z8A.png" alt="I set the progress 26 to show what it will be look like. Normally for 1:00 the progress must be 0."></a></p>
  
  <p>In my <code>onCreate</code> I set the progress 0</p>
  
  <pre><code>progressBar = (ProgressBar) findViewById(R.id.progressBar);
  progressBar.setProgress(0); 
  </code></pre>
  
  <p>And then, when my time runs in it's thread, the timer updates itself:</p>
  
  <pre><code>private class TimeRun implements Runnable {
  
      @Override
      public void run() {
          while (timeLeft &gt; 0) {
              try {
                  Thread.sleep(100);
                  timeLeft = timeLeft - 100;
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                      progressBar.setProgress(100 - (int) ((double) timeLeft / ((double) 60000) * 100));
                      if (timeLeft &lt; 10000)
                          textViewTimer.setText("0:0" + timeLeft / 1000);
                      else
                          textViewTimer.setText("0:" + timeLeft / 1000);
                  }
              });
          }
  }
  </code></pre>
  
  <p>When I run the activity, the progress bar is showing 100, thought it should have been 0 (black circle). And it shows no change during the run time. The text view updates normally, but progress bar shows no change.
  The logs show me that the progress is updating, but graphically there are no changes.</p>
  
  <p><a href="https://i.stack.imgur.com/XgWAD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XgWAD.png" alt="progress bar doesn&#39;t update"></a>
  I tried to update it by posting a Runnable, I checked this question too, but the answers didn't help me </p>
  
  <p><a href="https://stackoverflow.com/questions/4348032/android-progressbar-does-not-update-progress-view-drawable">android progressBar does not update progress view/drawable</a></p>
  
  <p>Can you suggest me any solution?</p>