FillDrawable
FillDrawable copied to clipboard
animation speed?
How to increase the animation speed?
Thanks for this lib
Hey!
As long as you can use any animation mechnism, you can configure anything as you wish. In sample I used Handler, but it could be easily achived with, for example, ValueAnimator.
final FillDrawable fillDrawable = ...;
final float fillPercent = 100.F; // the final fill percent to achieve
final ValueAnimator animator = ValueAnimator.ofFloat(0.F, 1.F);
animator.setEvaluator(new FloatEvaluator());
animator.setInterpolator(new AccelerateDecelerateInterpolator());
animator.setDuration(1500L); // here could be any value
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
final float fraction = animation.getAnimatedFraction();
fillDrawable.setFillPercent(fillPercent * fraction);
}
});
animator.start();
You are welcome!
Thankyou for the prompt reply
Just a comment. It works but the fillPercent should not be % but per unit, e.g. 0.5f
You are right @pellyadolfo , thanks for bringing this up 👍
Use values in range 0.0-1.0F to represent 0-100% progress (with 1.0F = 100%, 0.5F = 50%, etc)