-1

I need to have a Heart Pulse animation in my app such as this or this. I don't mind using an external resource as long as I'm able to control the pulse rate. After so much googling many had suggested that the android.graphics.Path should be used but then I have no idea of how should I get what I need.

So if anyone knows how to achieve such a thing ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
2hamed
  • 8,719
  • 13
  • 69
  • 112

1 Answers1

15

You can add a ObjectAnimator like this, creating a pulsating effect in your image

ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(ImageView,
                PropertyValuesHolder.ofFloat("scaleX", 1.2f),
                PropertyValuesHolder.ofFloat("scaleY", 1.2f));
        scaleDown.setDuration(300);

        scaleDown.setRepeatCount(ObjectAnimator.INFINITE);
        scaleDown.setRepeatMode(ObjectAnimator.REVERSE);

        scaleDown.start();

Another way to achive that is have a CustomClass and override your OnDraw method, creating a effect of growing or decrease increasing a variable and recalling invalidate(). I did these in another post to make my button background grow, if you want to follow this way it can be useful for you.

Pulsating Button Android

halfer
  • 19,824
  • 17
  • 99
  • 186
Francisco Durdin Garcia
  • 12,540
  • 9
  • 53
  • 95