Use the ValueAnimator class in android
final float startSize = o; // Size in pixels final float endSize = 30; final int animationDuration = 1000; // Animation duration in ms ValueAnimator animator = ValueAnimator.ofFloat(startSize, endSize); animator.setDuration(animationDuration); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { float animatedValue = (float) valueAnimator.getAnimatedValue(); tv.setTextSize(animatedValue); } }); animator.start();
link to this link ValueAnimator
Another solution is to use scaling animations in Textview or its parent layout.
ScaleAnimation scaleAnimation = new ScaleAnimation(0.7f, 1.1f, 0.7f, 1.1f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setDuration(600); viewZoom.startAnimation(scaleAnimation);
source share