自定义Animation
来源:互联网 发布:吴德周 知乎 编辑:程序博客网 时间:2024/06/11 07:32
//创建自定义动画//创建Animation的子类public class MyAnimation extends Animation {int mWidth;int mHeight;private Camera mCamera;//有必要的情况下,需要复写initialize()@Overridepublic void initialize(int width, int height, int parentWidth, int parentHeight) { super.initialize(width, height, parentWidth, parentHeight); mWidth=width; mHeight=height; setDuration(500); setFillAfter(true);//为真,则保持最后的显示效果 //设置默认插值器 效果是0到1; BounceInterpolator bounceInterpolator = new BounceInterpolator(); setInterpolator(bounceInterpolator); mCamera = new Camera();} //核心方法applyTransformation(),interpolatedTime是插值器,Transformation 通过其矩阵来实现动画 @Overrideprotected void applyTransformation(float interpolatedTime, Transformation t) {// super.applyTransformation(interpolatedTime, t);父类的applyTransformation是空实现,其四个子类才有具体的实现 Matrix matrix = t.getMatrix();/* //通过修改matrix来实现电视机关闭的效果 matrix.preScale(1, 1-interpolatedTime, mWidth/2,mHeight/2);*/ //Camera是3D轴修改的封装后的类,作用是修改 3D坐标轴 mCamera.save(); mCamera.rotateY(360*interpolatedTime); mCamera.getMatrix(matrix); mCamera.restore();//将修改后的效果作用到matrix上 //开始和结束时候的矩阵// matrix.preTranslate(mWidth/2,mHeight/2); matrix.postTranslate(mWidth/2,mHeight/2);}}
阅读全文
0 0
- 自定义Animation
- Android 自定义动画(Animation)
- Android自定义Animation动画
- 自定义Animation及运用
- android自定义animation
- Android自定义Animation动画
- 自定义ViewGroup、 动画Animation
- Android自定义Animation动画
- Android SurfaceView 自定义 Animation
- Android 自定义Animation动画
- 自定义动画Animation
- 继承Animation自定义动画
- Animation动画的解析与自定义Animation
- Android自定义可拖动组件+animation
- 第四十三天 自定义ViewGroup、Animation
- 自定义Animation动画,完成跑圈动作
- ios 开发学习日志 自定义animation 1
- Android 自定义Animation实现View摇摆效果
- 小述系列最终篇:说说《大道至易:实践者的思想》
- Python3之生成器
- 浏览器跨域的解决方案
- 单链表 实现Java栈的理解
- 简单SqlHelper
- 自定义Animation
- adb 常用命令
- 菜鸟的第三篇日志
- UVA 1586 Molar mass
- Spring-AOP和事务实践(注解方式
- scrapy安装及PyCharm的scrapy配置
- flowable EngineConfiguration的作用和继承关系(1)
- 在线视频解析下载教程合集(值得收藏)
- 【dp】树形dp真好玩,hdu6035多校第一场的 colorful tree