title: Android custom view invalidate() animation not triggering ondraw or draw
body: <p>I created a custom view class that draws a pie chart and animates it. First I had the class extending a drawable then applying the drawable to a view and it worked fine. I changed it so now the class extends a relative layout and I can use it in xml layouts. The method animateDraw() is a value animator and should be invalidating the view which triggers ondraw() but on draw is never triggered</p>
  
  <pre><code>public class PieView extends RelativeLayout {
  
  public PieView(Context context) {
      super(context);
  }
  
  public PieView(Context context, AttributeSet attrs) {
      super(context, attrs);
  
  }
  
  public PieView(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
  
  }
  
  private HashMap&lt;Integer, Integer&gt; mValues = new HashMap&lt;Integer, Integer&gt;();
  private Paint paint;
  private float totalArcElapsed;
  public boolean animating;
  private float dataSum = 0;
  
  public void setValues(HashMap&lt;Integer, Integer&gt; values) {
  
  
      this.paint = new Paint();
      paint.setAntiAlias(true);
      paint.setStyle(Paint.Style.FILL);
  
      for (Map.Entry&lt;Integer, Integer&gt; entry : mValues.entrySet()) {
          Integer key = entry.getKey();
  
          dataSum += (float) key;
      }
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      // TODO Auto-generated method stub
  
      Log.d(MyApp.TAG, "on draw");
      super.onDraw(canvas);
  }
  
  @Override
  public void draw(Canvas canvas) {
      super.draw(canvas);
      Log.d(MyApp.TAG, "draw");
      float startAngle = 0;
  
      RectF rectBounds = new RectF(getLeft(), getTop(), getRight(), getBottom());
  
      for (Map.Entry&lt;Integer, Integer&gt; entry : mValues.entrySet()) {
  
          float sliceValue = (float) entry.getKey();
          Integer colorRes = entry.getValue();
          paint.setColor(colorRes);
  
          float angleSweep = 360 * (sliceValue / dataSum);
  
          if ((startAngle + angleSweep) &lt; totalArcElapsed) {
  
              canvas.drawArc(rectBounds, startAngle, angleSweep, true, paint);
          }
          else {
  
              float portion = angleSweep - ((startAngle + angleSweep) - totalArcElapsed);
              canvas.drawArc(rectBounds, startAngle, portion, true, paint);
              break;
          }
  
          startAngle += angleSweep;
      }
  }
  
  public void animateDraw() {
      ValueAnimator animation = ValueAnimator.ofInt(0, 360);
      animation.setDuration(2000);
  
      animation.addUpdateListener(new AnimatorUpdateListener() {
  
          @Override
          public void onAnimationUpdate(ValueAnimator animation) {
              float fraction = animation.getAnimatedFraction();
              int value = (Integer) animation.getAnimatedValue();
              totalArcElapsed = value;
              Log.d(MyApp.TAG, totalArcElapsed + " ");
                              invalidate();
  
          }
      });
      animation.addListener(new AnimatorListener() {
  
          @Override
          public void onAnimationStart(Animator animation) {
  
              animating = true;
          }
  
          @Override
          public void onAnimationRepeat(Animator animation) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onAnimationEnd(Animator animation) {
              animating = false;
  
          }
  
          @Override
          public void onAnimationCancel(Animator animation) {
  
  
          }
      });
      animation.start();
  
  }
  </code></pre>
  
  <p>}</p>