Tween 补间动画(硬编码方式)
/** * Tween 补间动画 * * @author lilin * @date 2011-9-5 下午04:03:40 * @ClassName: Main * @Description: 通过硬编码的方式 */public class Main extends Activity implements OnClickListener {private Button b1, b2, b3, b4;private ImageView imageView;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);imageView = (ImageView) findViewById(R.id.ImageView01);b1 = (Button) findViewById(R.id.Button01);b2 = (Button) findViewById(R.id.Button02);b3 = (Button) findViewById(R.id.Button03);b4 = (Button) findViewById(R.id.Button04);b1.setOnClickListener(this);b2.setOnClickListener(this);b3.setOnClickListener(this);b4.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.Button01:// 创建Sacle(尺寸)变化动画Animation scaleAnimation = new ScaleAnimation(//0f, // 起始X坐标上的伸缩尺寸1f,// 结束X坐标上的伸缩尺寸0f, // 起始Y坐标上的伸缩尺寸1f,// 结束Y坐标上的伸缩尺寸Animation.RELATIVE_TO_SELF,// X坐标伸缩模式0.5f,// X坐标伸缩值Animation.RELATIVE_TO_SELF,// Y坐标伸缩模式0.5f// Y坐标伸缩值);scaleAnimation.setDuration(3000);// 创建Sacle(尺寸)变化动画imageView.startAnimation(scaleAnimation);// 开始动画break;case R.id.Button02:// 创建Alpha(渐变)动画Animation alphaAnimation = new AlphaAnimation(//0.1f,// 动画开始透明度1.0f// 动画结束透明度(取值范围0.0-1.0));alphaAnimation.setDuration(3000);imageView.startAnimation(alphaAnimation);break;case R.id.Button03:// 创建translate(位置变化)动画Animation translateAnimation = new TranslateAnimation(//10,// 起始X坐标100, // 结束X坐标10,// 起始Y坐标100// 结束Y坐标);translateAnimation.setDuration(3000);imageView.startAnimation(translateAnimation);break;case R.id.Button04:// 创建rotate(旋转)动画Animation rotateAnimation = new RotateAnimation(//0f, // 旋转开始角度+360f,// 旋转结束角度Animation.RELATIVE_TO_SELF, // X坐标伸缩模式0.5f,// X坐标伸缩值Animation.RELATIVE_TO_SELF, // Y坐标伸缩模式0.5f// Y坐标伸缩值);rotateAnimation.setDuration(3000);imageView.startAnimation(rotateAnimation);break;default:break;}}}?