你好,游客 登录 注册 搜索
背景:
阅读新闻

Android电视关闭的动画效果

[日期:2012-02-23] 来源:Linux社区  作者:duohuot [字体:大 中 小]

老式电视机关闭的时候画面一闪消失的那个效果:

首先创建一个TVOffAnimation继承于Animation:

  1. import Android.graphics.Matrix;  
  2. import android.view.animation.AccelerateDecelerateInterpolator;  
  3. import android.view.animation.Animation;  
  4. import android.view.animation.Transformation;  
  5.   
  6. public class TVOffAnimation extends Animation {  
  7.   
  8.     private int halfWidth;  
  9.     private int halfHeight;  
  10.   
  11.     @Override  
  12.     public void initialize(int width, int height, int parentWidth,  
  13.             int parentHeight) {  
  14.   
  15.         super.initialize(width, height, parentWidth, parentHeight);  
  16.         setDuration(500);  
  17.         setFillAfter(true);  
  18.         //保存View的中心点  
  19.         halfWidth = width / 2;  
  20.         halfHeight = height / 2;  
  21.         setInterpolator(new AccelerateDecelerateInterpolator());  
  22.           
  23.     }  
  24.   
  25.     @Override  
  26.     protected void applyTransformation(float interpolatedTime, Transformation t) {  
  27.   
  28.         final Matrix matrix = t.getMatrix();  
  29.         if (interpolatedTime < 0.8) {  
  30.             matrix.preScale(1+0.625f*interpolatedTime, 1-interpolatedTime/0.8f+0.01f,halfWidth,halfHeight);  
  31.         }else{  
  32.             matrix.preScale(7.5f*(1-interpolatedTime),0.01f,halfWidth,halfHeight);  
  33.         }  
  34.     }  
  35. }  
linux
相关资讯       Android开发 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款