Quite simply, I'm looking for an Android widget that lets me programmatically set an integer value and have it smoothly increment itself to get there. For instance, value is 10 and I update to 25, I want it to quickly zip through each number from 10 to 25 instead of just jump to 25. It's simple for aesthetics.
I'm guessing a spun off thread/interpolator, about 300ms, and a setText call on a TextView? Maybe there is a smarter way to do it, but mostly I'm just surprised I couldn't find one.
Anyone seen something along these lines?
If you have a TextView you could use a ValueAnimator for this, for example:
ValueAnimator va = ValueAnimator.ofInt(10, 25);
va.setInterpolator(new AccelerateDecelerateInterpolator());
va.setDuration(300);
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
Integer value = (Integer) animation.getAnimatedValue();
textView.setText(value);
}
});
This should give you the results you want. You can change interpolator for a slightly different effect.