'Animate TextView to increase double value and stop at some point?

I have a TextView showing double value. Double value is transferred from API response, and I want to add animation. I want to if, for example, the double value is 2.3, I want text View to increase shown number by 0.0 until 2.3, so it would be 0.1-0.2-0.3... etc. How can I do this? I have seen examples with Value Animator but they only work with integers. Ps. my code it's in Kotlin.



Solution 1:[1]

public void animateTextView(float initialValue, float finalValue, final TextView  textview) {

    ValueAnimator valueAnimator = ValueAnimator.ofFloat(initialValue, finalValue);
    valueAnimator.setDuration(1500);

    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {

            textview.setText(valueAnimator.getAnimatedValue().toString());

        }
    });
    valueAnimator.start();

}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Param