How to achieve shake animation programmatically?

前端 未结 2 1632
长情又很酷
长情又很酷 2021-02-19 03:15

How can I achieve shake/wobble animation in android programmatically. There is a AndroidViewAnimations library available through which we can get the effect. But I don\'t want t

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-19 03:55

    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();
    

提交回复
热议问题