日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

Android電視關(guān)閉的動畫效果

系統(tǒng) 2085 0
老式電視機(jī)關(guān)閉的時(shí)候畫面一閃消失的那個(gè)效果:

Android電視關(guān)閉的動畫效果

Android電視關(guān)閉的動畫效果

首先創(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

Android電視關(guān)閉的動畫效果


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

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

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 奉节县| 永泰县| 韶山市| 博湖县| 新郑市| 醴陵市| 景泰县| 鸡东县| 民勤县| 扎囊县| 太康县| 南皮县| 五家渠市| 玉林市| 阜新市| 静宁县| 即墨市| 区。| 巴彦淖尔市| 青田县| 腾冲县| 汽车| 交城县| 那坡县| 梁河县| 庆安县| 漳浦县| 安乡县| 平舆县| 临海市| 无锡市| 汾阳市| 台南市| 松潘县| 兰州市| 郑州市| 磴口县| 南岸区| 金湖县| 镇原县| 江西省|