老式電視機(jī)關(guān)閉的時(shí)候畫面一閃消失的那個(gè)效果:
首先創(chuàng)建一個(gè)TVOffAnimation繼承于Animation:
interpolatedTime表示的是當(dāng)前動畫的間隔時(shí)間 范圍是0-1
那么橫向來講前80%的時(shí)間我們要橫向拉伸到150%,縱向是直接減小,最后只留一條線。
后20%的時(shí)間里我們要橫向從150%壓縮至0%,縱向保持不變就好了,當(dāng)橫向?yàn)?的時(shí)候就全部消失了。
可能大家對于1+0.625f*interpolatedTime, 1-interpolatedTime/0.8f+0.01f,7.5f*(1-interpolatedTime),0.01f 這4個(gè)值比較疑惑,其實(shí)很簡單,這是一個(gè)一次函數(shù)的函數(shù)值。
然后在activity中直接可以用了
http://www.cnblogs.com/mudoot/articles/1985142.html


首先創(chuàng)建一個(gè)TVOffAnimation繼承于Animation:
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的中心點(diǎn) 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); } } }
interpolatedTime表示的是當(dāng)前動畫的間隔時(shí)間 范圍是0-1
那么橫向來講前80%的時(shí)間我們要橫向拉伸到150%,縱向是直接減小,最后只留一條線。
后20%的時(shí)間里我們要橫向從150%壓縮至0%,縱向保持不變就好了,當(dāng)橫向?yàn)?的時(shí)候就全部消失了。
可能大家對于1+0.625f*interpolatedTime, 1-interpolatedTime/0.8f+0.01f,7.5f*(1-interpolatedTime),0.01f 這4個(gè)值比較疑惑,其實(shí)很簡單,這是一個(gè)一次函數(shù)的函數(shù)值。
然后在activity中直接可以用了
View img = findViewById(R.id.imageView); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { img.startAnimation(new TVOffAnimation()); } });
http://www.cnblogs.com/mudoot/articles/1985142.html
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
