I want to create a custom interpolate to apply translate animation where the animation should go through the following function:
public static float easeIn(float t,float b , float c, float d) {
return c*(t/=d)*t + b;
}
where :
t: current time
b: start value
c: change in value
d: duration
I have found one to implement scale animation where if take only one parameter:
import android.view.animation.Interpolator;
public class MyInterpolator implements Interpolator {
public MyInterpolator() {
}
public float getInterpolation(float t) {
float x = 2.0f * t - 1.0f;
return 0.5f * (x * x * x + 1.0f);
}
}
how create in interpolate to make translate using the above function.
Short Answer: From the name I guess your easyIn should be an AccelerateInterpolator
The function you write is not what the interpolator can do. The interpolator doesn't care if it is a Scale-, Alpha- or TranslateAnimation.
The docs explains Interpolator getInterpolation like this:
A value between 0 and 1.0 indicating our current point in the animation where 0 represents the start and 1.0 represents the end
The interpolator provides a function that maps from the elapsed time (relatively) to the progress of the animation. You can imagine it in %, the getInterpolation(xy) will tell you
"If xy% of total duration is passed, how much % of total animation should be passed?"
Take LinearInterpolator as example. The implementation will look like this:
public float getInterpolation(float t) {
return t
}
Example: You animate from 0px to 200px with LinearInterpolator:
After 45% (0.45) of time 45% (return 0.45) of animation should be passed, which is 90px (200px*0.45)
Please read this for detailed information: