费话不多说,直接上代码


TVOffAnimation.java
package com.iaiai.activity;import android.graphics.Matrix;import android.view.animation.AccelerateDecelerateInterpolator;import android.view.animation.Animation;import android.view.animation.Transformation;/** *  * <p> * Title: TVOffAnimation.java * </p> * <p> * E-Mail: 176291935@qq.com * </p> * <p> * QQ: 176291935 * </p> * <p> * Http: iaiai.iteye.com * </p> * <p> * Create time: 2012-10-8 下午1:33:44 * </p> *  * @author 丸子 * @version 0.0.1 */public class TVOffAnimation extends Animation {private int halfWidth;private int halfHeight;@Overridepublic 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());}@Overrideprotected void applyTransformation(float interpolatedTime, Transformation t) {final Matrix matrix = t.getMatrix();if (interpolatedTime < 0.5) {matrix.preScale(1 + 0.625f * interpolatedTime, 1 - interpolatedTime / 0.8f + 0.003f, halfWidth, halfHeight);} else {matrix.preScale(7.5f * (1 - interpolatedTime), 0.003f, halfWidth, halfHeight);}}}


MainActivity.java
package com.iaiai.activity;import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;/** *  * <p> * Title: MainActivity.java * </p> * <p> * E-Mail: 176291935@qq.com * </p> * <p> * QQ: 176291935 * </p> * <p> * Http: iaiai.iteye.com * </p> * <p> * Create time: 2012-10-8 下午1:33:44 * </p> *  * @author 丸子 * @version 0.0.1 */public class MainActivity extends Activity {@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);findViewById(R.id.btn).setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {findViewById(R.id.root).startAnimation(new TVOffAnimation());}});}}


main.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/root"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="@android:color/white"    android:orientation="vertical" >    <TextView        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="@string/hello" />    <Button        android:id="@+id/btn"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:text="动画" /></LinearLayout>


更多相关文章

  1. android中图片的拖拉和缩放
  2. Android(安卓)3D图片切换
  3. Android(安卓)左右滑动 控件
  4. Android(安卓)TabSwitcher自定义控件
  5. 高德地图Android,绘制自定义定位蓝点、marker、面
  6. android中图片的拖拉和缩放
  7. android 自定义动画1
  8. Android(安卓)自定义Gallery
  9. 《Pro Android(安卓)Graphics》读书笔记之第四节

随机推荐

  1. android webkit 内核
  2. 关于WebVeiw的例子(一)
  3. Android中OpenCv编译的时候一些错误的总
  4. android系统开发sdcard
  5. 在Android中创建一种新的输入法(Creating
  6. android学习---SeekBar和RatingBar
  7. 【Android】悬浮按钮(FloatingActionButto
  8. Android(安卓)系统api实现定位及使用百度
  9. Android(安卓)定时让popupwindow消失
  10. Android代码性能优化技巧 (一)