Eddie
Eddie

Reputation: 31

Make an ImageView shake using only Java

I need to make an ImageView shake onClick using only java. I have looked at a couple other similar questions, but those are mainly XML. I a need it only using java.

Upvotes: 3

Views: 267

Answers (1)

Jayanth
Jayanth

Reputation: 6287

let's say that mView is the view you want to animate:

ObjectAnimator
  .ofFloat(mView, "translationX", 0, 25, -25, 25, -25,15, -15, 6, -6, 0)
  .setDuration(duration)
  .start();

answer credits Budius

Upvotes: 3

Related Questions