How to animate text inside a button

I would like the text to turn on and off in the blink / pulsate button. I know that I can use AlphaAnimation to achieve this effect, but from what I know, it affects the whole look of the button. Is there a way to implement this type of animation only by text inside a button?

+6
source share
1 answer

You can animate text color from standard color to transparent and vice versa.

 ObjectAnimator colorAnim = ObjectAnimator.ofInt(myButton, "textColor", Color.RED, Color.TRANSPARENT); colorAnim.setDuration(1000); colorAnim.setEvaluator(new ArgbEvaluator()); colorAnim.setRepeatCount(ValueAnimator.INFINITE); colorAnim.setRepeatMode(ValueAnimator.REVERSE); colorAnim.start(); 
+12
source

Source: https://habr.com/ru/post/957220/


All Articles