0

I'm trying to implement animation which draws a circle. It should look something like this gif except the color of the line should be all solid. Also my circle should start from 0 degrees and finish at 360. Any ideas ideas how to implement this? Examples would be appreciated.

enter image description here

Egis
  • 5,081
  • 5
  • 39
  • 61

1 Answers1

3

At its most basic level, this is the result of the drawArc() method called on a Canvas, either inside a View or a Drawable.

In respect to the animation, you can achieve it by using a ValueAnimator that sets the sweepAngle parameter used in the drawArc() method inside an AnimatorUpdateListener

Edit: For example, you would call getAnimatedFraction() on the Update Listener's ValueAnimator argument, which returns a float value beteween 0F and 1F, and multiply this by the target degree you would like to achieve (i.e. 300). Then use it to set the sweepAngle and invalidate the View to redraw it.

PPartisan
  • 8,173
  • 4
  • 29
  • 48
  • 1
    Thanks. I also found this sample which was really helpful. http://stackoverflow.com/a/29381788/1329901 – Egis Oct 20 '15 at 12:56
  • @Egidijus Yup! There's a few ways to do it to be fair. You could also create a custom `Drawable` and have it implement `Animatable`, but I prefer the methods outlined in my answer and the one in your link. – PPartisan Oct 20 '15 at 13:01