日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android电视关闭的闪屏动画效果

發(fā)布時間:2023/12/10 Android 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android电视关闭的闪屏动画效果 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

老式電視機關(guān)閉的時候畫面一閃消失的那個效果:?

?

?

首先創(chuàng)建一個TVOffAnimation繼承于Animation:?

首先創(chuàng)建一個TVOffAnimation繼承于Animation

然后在initialize里面設(shè)置一些參數(shù) 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;

@Override
public 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());

}

@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {

final Matrix matrix = t.getMatrix();
if (interpolatedTime < 0.8) {
matrix.preScale(1+0.625f*interpolatedTime, 1-interpolatedTime/0.8f+0.01f,halfWidth,halfHeight);
}else{
matrix.preScale(7.5f*(1-interpolatedTime),0.01f,halfWidth,halfHeight);
}
}
}

說明一下做法:

?

其中setInterpolator(new AccelerateDecelerateInterpolator())選擇一個先加速后減速的效果

最后動畫的部分里面

?

interpolatedTime表示的是當(dāng)前動畫的間隔時間 范圍是0-1

那么橫向來講前80%的時間我們要橫向拉伸到150%,縱向是直接減小,最后只留一條線。 后20%的時間里我們要橫向從150%壓縮至0%,縱向保持不變就好了,當(dāng)橫向為0的時候就全部消失了。 可能大家對于1+0.625f*interpolatedTime, 1-interpolatedTime/0.8f+0.01f,7.5f*(1-interpolatedTime),0.01f 這4個值比較疑惑,其實很簡單,這是一個一次函數(shù)的函數(shù)值 如圖為sx的變化曲線 然后在activity中直接可以用了 : View img = findViewById(R.id.imageView);
button.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
img.startAnimation(new TVOffAnimation());
}
});

/Files/mudoot/TVOffDemo.rar?

?

轉(zhuǎn)自:http://www.cnblogs.com/mudoot/articles/1985142.html

轉(zhuǎn)載于:https://www.cnblogs.com/shanzei/archive/2012/03/24/2415664.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的Android电视关闭的闪屏动画效果的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。