Is there a way to reduce the amplitude of bounce effect while using BounceInterpolator for animations in Android? By default, it causes a bounce effect much more than I desire.
Unfortunately, Android's BounceInterpolator doesn't provide that option. You'll need to write your own version to control the amplitude. Here is a simple version of the code that takes Amplitude and Frequency as Arguments in the Constructor. A simple web search will get you to the formula used below.
class MyBounceInterpolator implements android.view.animation.Interpolator {
double mAmplitude = 1;
double mFrequency = 10;
MyBounceInterpolator() {
}
MyBounceInterpolator(double amp, double freq) {
mAmplitude = amp;
mFrequency = freq;
}
public float getInterpolation(float time) {
return (float) (-1 * Math.pow(Math.E, -time/ mAmplitude) * Math.cos(mFrequency * time) + 1);
}
}
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With