Android的简单的TextView动画 [英] Android Simple TextView Animation

查看:158
本文介绍了Android的简单的TextView动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个,我想倒计时(3 ...... 2 ...... 1 ......事情发生)。

I've got a TextView that I would like to count down (3...2...1...stuff happens).

要使它更有趣,我想每一位数字开始完全不透明,淡出透明度。

To make it a little more interesting, I want each digit to start at full opacity, and fade out to transparency.

是否有这样做的一个简单的方法?

Is there a simple way of doing this?

推荐答案

尝试是这样的:

 private void countDown(final TextView tv, final count) {
   if (count == 0) { 
     tv.setText(""); //Note: the TextView will be visible again here.
     return;
   } 
   tv.setText(count);
   AlphaAnimation animation = new AlphaAnimation(1.0f, 0.0f);
   animation.setDuration(1000);
   animation.setAnimationListener(new AnimationListener() {
     public void onAnimationEnd(Animation anim) {
       countDown(tv, count - 1);
     }
     ... //implement the other two methods
   });
   tv.startAnimation(animation);
 }

我刚才输入出来,所以它可能无法编译原样。

I just typed it out, so it might not compile as is.

这篇关于Android的简单的TextView动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆