哪个网站的理财频道做的比较好,成都网站设计报价,做网站公司 蓝纤科技,wordpress加分类老式电视机关闭的时候画面一闪消失的那个效果#xff1a; 首先创建一个TVOffAnimation继承于Animation#xff1a; 首先创建一个TVOffAnimation继承于Animation 然后在initialize里面设置一些参数import android.graphics.Matrix;import android.view.animation.Accelerat…老式电视机关闭的时候画面一闪消失的那个效果 首先创建一个TVOffAnimation继承于Animation 首先创建一个TVOffAnimation继承于Animation 然后在initialize里面设置一些参数 import android.graphics.Matrix;import android.view.animation.AccelerateDecelerateInterpolator;import android.view.animation.Animation;import android.view.animation.Transformation;public class TVOffAnimation extends Animation {private int halfWidth;private int halfHeight; Overridepublic void initialize(int width, int height, int parentWidth,int parentHeight) {super.initialize(width, height, parentWidth, parentHeight); setDuration(500); setFillAfter(true);//保存View的中心点 halfWidth width / 2; halfHeight height / 2; setInterpolator(new AccelerateDecelerateInterpolator()); } Overrideprotected void applyTransformation(float interpolatedTime, Transformation t) {final Matrix matrix t.getMatrix();if (interpolatedTime 0.8) { matrix.preScale(10.625f*interpolatedTime, 1-interpolatedTime/0.8f0.01f,halfWidth,halfHeight); }else{ matrix.preScale(7.5f*(1-interpolatedTime),0.01f,halfWidth,halfHeight); } }} 说明一下做法 其中setInterpolator(new AccelerateDecelerateInterpolator())选择一个先加速后减速的效果 最后动画的部分里面 interpolatedTime表示的是当前动画的间隔时间 范围是0-1 那么横向来讲前80%的时间我们要横向拉伸到150%纵向是直接减小最后只留一条线。 后20%的时间里我们要横向从150%压缩至0%纵向保持不变就好了当横向为0的时候就全部消失了。 可能大家对于10.625f*interpolatedTime, 1-interpolatedTime/0.8f0.01f7.5f*(1-interpolatedTime),0.01f 这4个值比较疑惑其实很简单这是一个一次函数的函数值 如图为sx的变化曲线 然后在activity中直接可以用了 View img findViewById(R.id.imageView);button.setOnClickListener(new OnClickListener() { Overridepublic void onClick(View v) { img.startAnimation(new TVOffAnimation()); } }); /Files/mudoot/TVOffDemo.rar 转自http://www.cnblogs.com/mudoot/articles/1985142.html转载于:https://www.cnblogs.com/shanzei/archive/2012/03/24/2415664.html