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
Just to provide another possible answer to the question. The below animation file need to be put under res/anim folder :
shake.xml
And to use it in code (Here in Kotlin) :
val animShake = AnimationUtils.loadAnimation(requireContext(), R.anim.shake)
mView.startAnimation(animShake)
Animation explanation:
If you want 1000ms of duration, you need to divide this by the number of step in your anim. Ex. with 5 steps: 1000/5 = 200 So if you put 200 of duration for each step, all will take same time to end
The "startOffset" parameter need to specify after what time the animation need to start (Here we wanted to sum all of before operations)
The "fromXDelta" parameter is your started point at each step, based on the previous step.