Android简单TextView动画

Rob*_*Rob 7 animation android text textview zebra-striping

我有一个TextView,我想倒数(3 ... 2 ...... 1 ......事情发生了).

为了使它更有趣,我希望每个数字以完全不透明度开始,并淡出透明度.

有一个简单的方法吗?

dmo*_*mon 13

尝试这样的事情:

 private void countDown(final TextView tv, final int count) {
   if (count == 0) { 
     tv.setText(""); //Note: the TextView will be visible again here.
     return;
   } 
   tv.setText(String.valueOf(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);
 }
Run Code Online (Sandbox Code Playgroud)

我只是输入它,所以它可能不会按原样编译.