Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/byteszero/tvoffanimation
仿电视关闭的一个动画效果
https://github.com/byteszero/tvoffanimation
Last synced: 4 days ago
JSON representation
仿电视关闭的一个动画效果
- Host: GitHub
- URL: https://github.com/byteszero/tvoffanimation
- Owner: BytesZero
- License: apache-2.0
- Created: 2015-03-27T04:08:27.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-15T05:04:56.000Z (over 9 years ago)
- Last Synced: 2023-11-05T13:22:26.757Z (about 1 year ago)
- Language: Java
- Size: 2.56 MB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TVOffAnimation
仿电视关闭的一个动画效果
#仿电视关机效果的动画
- **效果图**![这里写图片描述](https://github.com/yy1300326388/TVOffAnimation/blob/master/image/tvoffanimation.gif)
- **主要代码**
``` java
package com.zhengsonglan.tvanimation;import android.graphics.Matrix;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Transformation;/**
* Created by zsl on 2015/3/27.
*/
public class TVOffAnimation extends Animation {
int halfWidth;
int halfHeight;@Override
public void initialize(int width, int height, int parentWidth, int parentHeight) {
super.initialize(width, height, parentWidth, parentHeight);
//设置动画时间为700毫秒
setDuration(700);
//设置动画结束后就结束在动画结束的时刻
setFillAfter(true);
//保存View的中心点
halfWidth=width/2;
halfHeight=height/2;
//设置动画先加速后减速
setInterpolator(new AccelerateDecelerateInterpolator());
}@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
final Matrix matrix=t.getMatrix();
//interpolatedTime是从0~1的一个变化,所以我们前80%让动画缩小成一个线,后20%保持线的高度缩小线的宽度
if (interpolatedTime<0.8){
matrix.preScale(1+0.625f*interpolatedTime,1-interpolatedTime/0.8f+0.01f,halfWidth,halfHeight);
}else{
matrix.setScale(7.5f*(1-interpolatedTime),0.01f,halfWidth,halfHeight);
}}
}```
- **bolg地址**>[点击这里,欢迎指正](http://blog.csdn.net/yy1300326388/article/details/44674219)