本文介绍了如何为按钮内的文本设置动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让按钮内的文本闪烁/闪烁。我知道我可以使用 AlphaAnimation 来达到这种效果,但是据我所知,它作用于整个按钮视图。有没有一种方法可以仅对按钮内的文本实施这种动画?

I would like to have text within a button blink/pulsate on and off. I know I can use AlphaAnimation to achieve this effect, but from what I know this acts on the entire button view. Is there a way to implement this type of animation on just the text within the button?

推荐答案

您可以为文本颜色设置动画您的标准颜色变为透明并再次返回

You could animate the text color from your standard color to transparent and back again

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();

这篇关于如何为按钮内的文本设置动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 02:45